Static keyword can be applied to
Class, field, method, properties, operator, event and constructors.
Static member belongs to the class and not to any object of the class.
They can be used without creating the instance of the class.
For e.g. Static Void Main()
It is called by the operating system on program execution
To access the static member we’ll use
When a variable is declared as static internally what happens is that all the instances of the class share the same static variable. A static variable is initialized when its class is loaded. If not
initialized explicitly then
it is initialized to zero for numeric variable
null in case of object references
false for boolean
StaticMethod– they can only contain static member and call other static method.
If we need to access them than it can be done through the object of that class
public static void getNameThroughStatic(Game g)
g.getGameName(); // accessing static method
When to use them?
Well we can use them when we need to maintain information applicable to the entire class
suppose we have a class Employees there we can have a static count variable to keep track of no of employees.
static in count=0;
What are Static Constructor?
They can be used to initialize the static variables.
They are called automatically and before the instance constructor (if called any).
for above class
static Employees() // no other access modifiers for them
What are static Classes?
A class whose objects can’t be created and which can only have static members. They can’t be inherited as well.
They can have static constructor
Why use static Classes?
It can be used to group related static method.
Hi to add rows and columns to Gridveiw dynamically what
we will do is that
1) Create a DataTable object to which than we will bind the GridView
DataTable dt=new DataTable();
2) IF you need two columns than create two DataColumn object
DataColumn dCol1=new DataColumn(FirstC, typeof(System.String)); // string FirstC=”column1″
DataColumn dCol2=new DataColumn(SecondC, typeof(System.String)); // string SecondC=”column2″
Add it to the table
3)Run the loop for as many rows you want to add.
// say you want to add two rows
DataRow row1 = dt.NewRow();
row1 [FirstC] = “One”;
row1 [SecondC] =”Two”
Now iterate through each datacolumn and create a BoundField foreach column
foreach (DataColumn col in dt.Columns)
BoundField bField = new BoundField
bField.DataField = col.ColumnName;
bField.HeaderText = col.ColumnName;
GridView1.DataSource = dt;
//Bind the datatable with the GridView.
The internal access modifier can be applied to
Classes and it’s member
Structure and it’s member
This way it is available to all the files within that assembly.
Particularly useful when creating software components.
It can be used in conjunction with protected to produce
protected internal access modifier
It can be applied only to
It is available withing it’s own assembly or to derived types.
Say if we create an Class Library which has a class like
public class MyClass
And then you create
Now we create new project say a windows application and add a refrence to that dll
And can create the object of that class lik
MyClass my=new MyClass();
this works fine,
now if we modify the definition of the class by replacing public with internal and update the assembly
internal class MyClass
This time if we try to create the object of MyClass which is inside our referenced assembly
The error which we will get is
MyClass is inaccessible due to its protection level.
That’s why they are basically used in component development so that any other class couldn’t be able to access it i.e. create objects of it.
Value types (primitive type) ( simple type) are variable that contain their data directly.
They don’t contain reference to data stored elsewhere in memory.
Instances of values types are stored in an area of memory called stack where it is easy for the runtime to perform CRUD operation with minimal overhead.
Now what exactly is STACK based memory-
It is regions of memory where data is added or removed in a Last-In-First-Out manner.
each thread has a reserved region of memory referred to as its stack.
When a function executes, it may add some of its state data to the top of the stack; when the function exits it is responsible for removing that data from the stack. If a region of memory lies on the thread’s stack, that memory is said to have been allocated on the stack.
Thus stack allocation is very simple and typically faster.
Another advantage is that memory on the stack is automatically reclaimed when the function exits, which can be convenient for the programmer.
A disadvantage of stack based memory allocation is that a thread’s stack size can be as small as a few dozen kilobytes. Allocating more memory on the stack than is available can result in a crash .
Another disadvantage is that the memory stored on the stack is automatically deallocated when the function that created it returns, and thus the function must copy the data if they should be available to other parts of the program after it returns.
The are around 300 value types in .NET Framework. Most frequently used one are
System.SByte, Byte,Int16,Int32,UInt32,Inte64,Single,Double,decmal,char, boolean, datetime
Follow the following steps for creating subscriptions
1. Log into the reporting server: http://crmServer/reports
2. Click on _MSCRM Subscriptions Folder
3. Click on the report for which the subscription needs to be created
4. Click on the Subscriptions Tab
5. Click on New Subscription
6. Under Report Delivery Options, choose ‘Report Server File Share’
7. Provide details for the File Name as mentioned below
8. Provide the path of the folder where you want to save this subscription. This folder should be in the root directory of the reporting server. The person who is creating the subscription should have Read/Write Access to this folder.
For Ex: In the development server, a folder called ‘SubscribedReports’ has been created in the C drive. If a person called DomainName\XYZ’ is creating the subscription, then DomainName\XYZ’ should have write access to the ‘Subscribed Reports’ folder. The path to be provided in the reporting server subscription page would be ‘\\.’
9. Choose the render format : PDF format
10. Provide the Username/Password.
11. Under Subscription Processing Options, click on the button ‘Select Schedule’
12. Choose the scheduling date and time and then click on OK – Scheduling Every Monday at 10.00AM for all the reports
13. Under Report Parameter Values, choose the parameters that would be applicable for the specified subscription.
14. When all of the above have been completed, click on OK.
To find the opportunity record shared with a particular user in Microsoft Dynamics Crm
select o.name as OpportunityName,p.AccessRightsMask from opportunityBase o
left join PrincipalObjectAccess
p on p.objectid=o.opportunityid left join systemuser u
on p.principalid=u.systemuserid where u.fullname=’nishant r’
AccessRightsMask values and what they mean
AppendAccess 4 – Specifies the right to append the specified object to another object.
AppendToAccess 8 – Specifies the right to append another object to the specified object.
AssignAccess 0x80 -Specifies the right to assign the specified object to another security principal.
CreateAccess 0x10 -Specifies the right to create an instance of the object type.
DeleteAccess 0x20 -Specifies the right to delete the specified object.
ReadAccess 1 -Specifies the right to read the specified type of object.
ShareAccess 0x40 -Specifies the right to share the specified object.
WriteAccess 2 – Specifies the right to update (write to) the specified object.
3– Read + Write
65539– Read + Write + Delete
851991– All the rights
262145– Share+Read etc…
फिर मिलते हें