string strCheck = '';
bool checkString = String.IsNullOrEmpty(strText);
string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
IEnumerable<string> query =
Enumerable.Select (
Enumerable.OrderBy (
Enumerable.Where (
names, n => n.Contains ("a")
), n => n.Length
), n => n.ToUpper()
);
string strReverse ="";
string straoriginal = "Test";
if ((string.Compare(strOriginal, strReverse , false)) < 0)
{
MessageBox.Show("Less");
}
else if ((string.Compare(strOriginal, strReverse , false)) > 0)
{
MessageBox.Show("Greater");
}
else if ((string.Compare(strOriginal, strReverse , false)) == 0)
{
MessageBox.Show("Equal");
}
string strReverse ="";
string straoriginal = "Test";
string strReverse= Microsoft.VisualBasic.Strings.StrReverse(strOriginal);
MessageBox.Show(strReverse);
Progessive form
IEnumerable<string> filtered = names.Where (n => n.Contains ("a"));
IEnumerable<string> sorted = filtered.OrderBy (n => n.Length);
IEnumerable<string> finalQuery = sorted.Select (n => n.ToUpper());
Output
Harry
Mary
Jay
Jay
Mary
Harry
JAY
MARY
HARRY
string string1= "Split function";
string [] SplitString = string1.Split(new Char [] {' '});
MessageBox.Show(Convert.ToString(SplitString [0]));
MessageBox.Show(Convert.ToString(SplitString [1]));
Fluent query - LINQ
string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
IEnumerable<string> query = names
.Where (n => n.Contains ("a"))
.OrderBy (n => n.Length)
.Select (n => n.ToUpper());
Simple Filter Query
from n in new[] { "Tom", "Dick", "Harry" }
where n.Contains ("a")
select n
Ouput: Harry
string string1 = "Replace string";
string finalstring= string1 .Replace("replace", "Replaced");
MessageBox.Show("Final Value : " + finalstring);
Extension method
(new[] {"T", "D", "H"} ).Where (n => n.Length >= 4)
string string1= "This is a substring function";
string search= "sub";
int charFirst= string1.IndexOf(search);
MessageBox.Show("String at : " + charFirst);
// description of your code here
string[] names = { "T", "D", "H" };
IEnumerable<string> filteredNames =
System.Linq.Enumerable.Where (names, n => n.Length >= 4);
foreach (string n in filteredNames)
Console.Write (n + "|");code>
int[] listA= { 1,2,3};
int[] ListB = { 1,5,6,4};
var result = listA.Except(listB);
foreach (var n in result)
{
Console.WriteLine(n);
}
Dim numbersList() = {5, 4, 1, 3}
Dim skippedList= From n In numbersList Skip(2)
For Each n In skippedList
Console.WriteLine(n)
Next
Dim numbersList() = {5, 4, 1, 3}
Dim takeThree= numbersList.Take(3)
For Each n In takeThree
Console.WriteLine(n)
Next