Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5988019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:53:58+00:00 2026-05-22T22:53:58+00:00

I have a datatable which contains following data as SrNo Roll Name 1 1

  • 0

I have a datatable which contains following data as

SrNo Roll  Name
1    1     XYZ
99   45    ABC
150  120   POQ
10   9     RTY
190  180   MNZ

According to the range of of srNo the output should be derived & there should be a additional column Result should be added & according to the range the result should be filled with 0 or 1(if range is between 0-100 then result should be 0 if range is between 100-200 then result should be 1)

So the output will be

SrNo Roll  Name Result
1     1     XYZ  0
99    45    ABC  0
10    9     RTY  0

150   120   POQ   1

190  180   MNZ    1

I want to implement through linq

Please suggest any!!!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:53:58+00:00Added an answer on May 22, 2026 at 10:53 pm
    SrNo    Roll    Name    Result
    1       1       XYZ     0
    99      45      ABC     0
    10      9       RTY     0
    150     120     POQ     1
    190     180     MNZ     1
    

    Try this:

    var dt = new DataTable();
    dt.Columns.Add(new DataColumn("SrNo", typeof (int)));
    dt.Columns.Add(new DataColumn("Roll", typeof (int)));
    dt.Columns.Add(new DataColumn("Name", typeof (string)));
    
    dt.Rows.Add(1, 1, "XYZ");
    dt.Rows.Add(99, 45, "ABC");
    dt.Rows.Add(150, 120, "POQ");
    dt.Rows.Add(10, 9, "RTY");
    dt.Rows.Add(190, 180, "MNZ");
    
    var result = from r in dt.AsEnumerable()
                 orderby (r.Field<int>("Roll") >= 100) ascending
                 select new
                            {
                                SrNo = r.Field<int>("SrNo"),
                                Roll = r.Field<int>("Roll"),
                                Name = r.Field<string>("Name"),
                                Result = Convert.ToInt32(Math.Floor(r.Field<int>("Roll")/100.0))
                            };        
    
    Console.WriteLine(
            "{0}\t{1}\t{2}\t{3}",
            "SrNo",
            "Roll",
            "Name",
            "Result");
    
    foreach (var row in result)
    {
        Console.WriteLine(
            "{0}\t{1}\t{2}\t{3}",
            row.SrNo,
            row.Roll,
            row.Name,
            row.Result);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable which contains data in this format. I want to convert
I have a datatable which contains 10 rows. I now need to insert 11th
I have a gridview which contains a text box as a template field.the grid
Q: I have a gridview which contains text box as a template field.The grid
I have a jQuery Datatable with 3 headers. One header contains two radio buttons,
I have 2 listboxes. One contains all the department which are unassigned and other
I have an object (Ticket), which has a list of other objects (Message). Message
In continuation for my latest ponders about locks in C# and .NET, Consider the
Due to a recent issue i had some days ago (you can check this
Does any body know how to write an XML from a Dataset that has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.