Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
var numb = (from st in obj.Wishlist_tables
                join X in obj.movie_details on st.movie_id equals X.Id
                where st.username == Session["user"].ToString()
                select new { X.price }).ToArray();
    int x = numb.Count();
    int[] ary = new int[x];
    Int32[] data = new Int32[x];
    int sum = 0;
    for (int i = 0; i < x; i++ )
    {
        data[i] =Convert.ToInt32(numb[i]);

    }

    for (int j = 0; j < x; j++)
    {
        sum += data[j];
    }

    lbl_totalprice.Text = sum.ToString();
}

this is the query
1st i want to find out the values from database by linq which is fond and i puted that values in a var type varible numb now i want to store these values in array and then i want to add ol of these valus
Posted
Comments
BillWoodruff 16-Sep-13 1:15am    
What is the problem right now ? And, why do you declare int[] ary, and never use it ?

Since you know how to use Linq: how about:
lbl_totalprice.Text = numb.Sum(amt => Convert.ToInt32(amt)).ToString();
Note that code assumes that every entry in 'numb is an integer: so, it will cause a System.FormatException error, if any item in numb is not an integer.
 
Share this answer
 
Comments
Omprakash Kukana 16-Sep-13 3:16am    
i hav problem tha i hv ol the values in data[i] 200, 300 from datbase now i want to add these values how can i do this?
Convert string[] to int[] in one string of code using LINQ

Check it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900