Sunday, February 20, 2011
where T: IComparable , new()
In C# we have generic constraints like this to indicate a where clause to which the class must comply.
Here sortedlist is using a type T. This type must implement the Icomparable interface. The new() states that the type T must have a constructor.
Thursday, February 17, 2011
We have const variables and read only variables. Is there a difference between them?
When you declare a const variable it has to be given a value at the time of declaration.
public const int a = 5;
When you declare read only variables you can give a value at the run time. You don’t have to give the value at the time of declaration. But the thing is you have to give the value in the constructor. You cannot give a value anywhere else.
public readonly int b;
public read(int a)
b = a ;
Const variables are by default static variables.
One major difference is that you don’t have to implement all the methods in the abstract classes, unless all the methods are declared abstract.
In an interface all the methods are abstract hence they would have to be implemented in the class that implements the interface. Also there can be no variables and method bodies where as in an abstract class you can have methods with method bodies(implementation)
You can have methods in your base class with virtual signature and if you want to use the same method in your child class you need to use the term override.
public class a
public virtual int methodA()
public class B : a
public override int methodA()
You have a the same method in both base and derived class and when you compile the compiler would give you an error saying one method has to overridden. By putting new keyword infront of the child class method you can do this and this is called member shadowing.
Monday, February 14, 2011
public class A
Public class B :A
B b = new B();
What do you think? Will A constructor run before or B Constructor run?
It would be the base class constructor(A) that would be running before the child constructor(B). Not sure? Run the above code yourself and find out.
There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...
There is a bit of change in CRM 2011 than CRM 4. The code is below. Microsoft.Xrm.Sdk. EntityReference Moniker1 = new Microsoft.Xrm.S...
Error message “User does not have send-as privilege.” when sending emails programmatically in CRM 2011We were working on sending emails programmatically using CRM and all were working fine. Suddenly we got this error when we tried to send an ...
When you create a new security role from scratch and then assign only that role to a system user and when you log to the CRM site you might ...