If you want to use a Dictionary type of collection with duplicate key values you can go with Lookup
more details read: http://msdn.microsoft.com/en-us/library/bb460184.aspx
Tip Of The Day
What you Learned Today?
Monday, June 6, 2011
Wednesday, May 25, 2011
Registry Hacks to Make Your PC Faster
http://www.pcworld.in/how-to/6-registry-hacks-make-your-pc-faster
Monday, May 23, 2011
Latest way of debugging using Debugger Canvas
There is a latest way of debugging in VS please read this
Thursday, May 19, 2011
Wednesday, May 18, 2011
Lazy in C#
If you want to initialize a class as lazy Initialization you can go with Lazy key word.
Lazy _expensive = new Lazy
(() => new Expensive(), true);
Note: If you pass true as parameter,it will be thread safe else as false, it will not be thread safe.
If for a single -thread or single ton class Lazy is best
Lazy
(() => new Expensive(), true);
Note: If you pass true as parameter,it will be thread safe else as false, it will not be thread safe.
If for a single -thread or single ton class Lazy is best
If you want to return a query with Default if its Empty?
If you want to return a query with default value if it is empty you can go with DefaultIfEmpty
void Main()
{
Coder coder = new Coder("Jon");
List coderCollection = new List()
{
new Coder("Anish"),
new Coder("marokey"),
};
var result = coderCollection.Where(r => r.Name == "Pat").DefaultIfEmpty(coder);
}
// Define other methods and classes here
class Coder
{
public string Name;
public Coder(string Name)
{
this.Name = Name;
}
}
void Main()
{
Coder coder = new Coder("Jon");
List
{
new Coder("Anish"),
new Coder("marokey"),
};
var result = coderCollection.Where(r => r.Name == "Pat").DefaultIfEmpty(coder);
}
// Define other methods and classes here
class Coder
{
public string Name;
public Coder(string Name)
{
this.Name = Name;
}
}
Order by with out Culture
If you want to do some operations without any culture you can do with the help of StringCompare.Ordinal or StringCompare.OrdinalIgnoreCase.
void Main()
{
string[] nonCulture = { "äax", "ääü", "äbü" };
IEnumerable orderNonCulture = nonCulture.OrderBy( r => r, StringComparer.Ordinal);
orderNonCulture.Dump();
}
void Main()
{
string[] nonCulture = { "äax", "ääü", "äbü" };
IEnumerable
orderNonCulture.Dump();
}
Subscribe to:
Posts (Atom)