Visual studio 2010 is great IDE and i am discovering everyday some thing new. Today i have discovered one of fantastic option to increase performance of your visual studio IDE. Visual Studio 2010 has option when we enabled it it will automatically adjust the visual and client experience as per your hardware configuration. It will increase the performance of visual studio and productivity in lower hardware also. You can find that checkbox under Tools->General-> Automatically adjust visual experience based on client performance. There are two checkbox is given one for above and another for Rich User Experience but they may decrease your visual studio performance. Like following.
Indexer class in C#
While taking interviews for Microsoft.NET i often ask about indexer classes in C#.NET and i found that most of people are unable to give answer that how we can create a indexer class in C#.NET. We know the array in C#.NET and each element in array can be accessed by index same way for indexer class a object was class can be accessed by index. Its very easy to create a indexer class in C#. First lets looks some points related to indexer class in C#.
- Indexer class object can be accessed by index only.
- We can use same mechanism to access object of indexer class as we are doing it for array.
- You can can specify any valid C# type as return type of indexer classes.
- You must have to create a property with parameter using this keyword for indexer class.
- You can also implement multi parameter indexer also.
Let’s create simple indexer class with single parameter and for string type.
public class MyIndexer
{
private string[] MyIndexerData;
private int SizeOfIndexer;
//declaring cursor to assing size of indexer
public MyIndexer(int sizeOfIndex)
{
this.SizeOfIndexer = sizeOfIndex;
MyIndexerData = new string[SizeOfIndexer];
}
public string this[int Position]
{
get
{
return MyIndexerData[Position];
}
set
{
MyIndexerData[Position] = value;
}
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int indexSize=5;
MyIndexer objMyIndexer = new MyIndexer(indexSize);
for (int i = 0; i < indexSize; i++)
{
objMyIndexer[i] = i.ToString();
Console.WriteLine("Indexer Object Value-[{0}]: {1}",
i, objMyIndexer[i]);
}
Console.ReadKey();
}
}
}
Technorati Tags: Indexer,C#,Array
Microsoft.NET 4.0/VB.NET 10 Automatic Properties
In C# we are having automatic properties since C# 3.5 framework but now with Microsoft.NET 4.0 Framework VB.NET 10.0 version we are also having automatic properties for VB.NET Also.
Like in C# we can define automatic like following.
Public string TestProperty
{
get;
set;
}
Public Property TestProperty As String