Good one Richard.
David McGraw
Posts
-
change image every day c# Linq -
How to query a Dataset using LINQ?To avoid null values in your linq result, then you need to write the query like as shown below.
var q = from a1 in dt\_Jobs.AsEnumerable() where !string.IsNullOrEmpty(a1.Field("City")) orderby a1.Field("City") select a1.Field("City"); var lstCity = q.Distinct().ToList(); cboCity.DataSource = lstCity;
To know how to use linq with dataset, check following article it will help you. LINQ to Dataset with Example[^]
-
Not understanding use of return statement in c#.Hi Hassan, You are getting result 100 because your function abc(ref int i) is accepting ref type parameter. Generally, the ref keyword is used to pass parameter as a reference this means when the value of parameter is changed in called method, then that will get reflected in calling method also. Whenever the following function executed, the result of value of j will be assigned to your parameter i.
public static int abc(ref int j)
{
j = 100;
return j;
}That's the reason you are getting i values as 100 even after you change return statement as "return 0". If you want to know more about return statement and ref keyword check following topics it will help you understand how & when to use these keywords clearly in c#. Ref Keyword in C#[^] Return Statement in C#[^]