My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Saturday, 14 July 2018
Friday, 13 July 2018
Thursday, 12 July 2018
Select ,Any and All operator in Linq C#
using ConsoleApplication3.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
List<Employee> li = new List<Employee>()
{
new Employee{id=1,name="Ali",salary=50000},
new Employee{id=2,name="Ahmed",salary=30000},
new Employee{id=3,name="Ahsan",salary=50000},
new Employee{id=4,name="Asim",salary=40000},
new Employee{id=5,name="Asad",salary=10000},
};
// var list = li.Select(x => new { ID = x.id, Name = x.name });
//var list = li.ToList();
//foreach (var item in list)
//{
// Console.WriteLine("ID: " + item.id + "\nName" + item.name);
//}
//bool a = li.All(x => x.salary >= 10000);
bool b = li.Any(x => x.salary > 30000);
Console.WriteLine(b);
}
}
}
-----------------------------------------------------------------------------------------------
class Employee
{
public int id { get; set; }
public string name { get; set; }
public int salary { get; set; }
}
Wednesday, 11 July 2018
Join Query in Linq C#
using ConsoleApplication2.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<department> deplist = new List<department>
{
new department{deptid=1, deptname="HR"},
new department{deptid=2, deptname="Marketing"},
new department{deptid=3, deptname="IT"},
new department{deptid=4, deptname="Accounts"},
};
List<Employee> emplist = new List<Employee>
{
new Employee{empid=101,name="ali",deptfkid=1},
new Employee{empid=102,name="ahmed",deptfkid=2},
new Employee{empid=103,name="ahsan",deptfkid=1},
new Employee{empid=104,name="bilal",deptfkid=3},
new Employee{empid=105,name="zahid",deptfkid=1},
new Employee{empid=106,name="fahad",deptfkid=2},
};
var joinlist = emplist.Join(deplist, emp => emp.deptfkid, dep => dep.deptid, (emp, dep) => new
{
empid=emp.empid,
name=emp.name,
deptname=dep.deptname
});
foreach (var item in joinlist)
{
Console.WriteLine("-------------------");
Console.WriteLine("id: "+item.empid);
Console.WriteLine("Name: " + item.name);
Console.WriteLine("Department: " + item.deptname);
Console.WriteLine("-------------------");
}
Console.ReadKey();
}
}
}
----------------------------------------------------------------------------------------------------
class department
{
public int deptid { get; set; }
public string deptname { get; set; }
}
-----------------------------------------------------------------------------------------------
class Employee
{
public int empid { get; set; }
public string name { get; set; }
public int deptfkid { get; set; }
}
Tuesday, 10 July 2018
Monday, 9 July 2018
Group By and ToLookup in Linq C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class student
{
public int studentID { get; set; }
public string studentName { get; set; }
public int Age { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<student> li = new List<student>()
{
new student() { studentID = 5, studentName = "Ron" , Age = 21 },
new student() { studentID = 6, studentName = "Chris", Age = 18 },
new student() { studentID = 7, studentName = "Rob",Age = 19 },
new student() { studentID = 8, studentName = "Rob",Age = 21 },
new student() { studentID = 1, studentName = "John", Age = 18 },
new student() { studentID = 2, studentName = "Steve", Age = 21 },
new student() { studentID = 3, studentName = "Bill", Age = 25 },
new student() { studentID = 4, studentName = "Ram" , Age = 19 },
new student() { studentID = 9, studentName = "Bill",Age = 19 },
};
// var agegroup = li.GroupBy(x => x.Age).ToList();
var agegroup = li.ToLookup(x => x.Age).ToList();
foreach (var group in agegroup)
{
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("====AGE:"+group.Key+"====");
Console.ForegroundColor = System.ConsoleColor.Red;
foreach (var item in group)
{
Console.WriteLine(item.studentName);
}
}
}
}
}
Subscribe to:
Posts (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Load event: pictureBox3.Image = Image .FromFile( @"C:\Users\salman\Documents\Visual Studio 2013\Projects\WindowsFormsApplication3\W...