Where inDataType = data type of the input &
outDataType = data type of the output
eg.: Func
we can initiate Delegate Func in different ways ...some them are ........
1. We can directly give some function to Func.
class Program
{
static void Main(string[] args)
{
Func
string name = "this is func example";
Console.WriteLine(strString(name));
Console.ReadLine();
}
public static string Upperconversion(string s)
{
return s.ToUpper();
}
}
Here Function Upperconversion is directly given Func.
2.We can directly give delegate insted of any function to the Func.
static void Main(string[] args)
{
Func
{ return s.ToUpper();};
string name = "this is func example";
Console.WriteLine(strString(name));
Console.ReadLine();
}
3.We can use lamda expression for Func.
static void Main(string[] args)
{
Func
string name = "this is func example";
Console.WriteLine(strString(name));
Console.ReadLine();
}
example that you can understand.
string[] words = { "Hindi", "Marathi", "English", "Gujarati" };
Func
IEnumerable
foreach (int word in aWords)
Console.WriteLine(word);
Console.ReadLine();
0 comments:
Post a Comment