Skip to main content

Posts

Showing posts from December, 2008

Static in C#

Staic Member: You can access static member through the name of the class in which it is declared. E.g. className.StaticMethod(); You cannot access a static member through the instance of its class. In C# there are no global methods. Static methods are similar to global method but with the advantage that they have access to local members. Equivalent of Static in VB.Net is Shared (and not Static which creates a variable that exists throughout the lifecycle of the program. Also it is not shared among different instance of the class.) For static methods to access the non static methods of the same class, they must create instance of the class. Static Constructor: It is guarnteed to run before the instance of the class is created. You cannot control when it will run though. No access modifiers are allowed on static contructors. You can use initializer instead of static constructor. Static class: useful in creating small utility class holding static methods. Also it makes sure that you dont

Copy Constructor

C# doesn't have Copy constructor like C++. Instead it provides ICloneable interface which has Clone method. Class that supports the idea of copy constructor should implement ICloneable interface and then implement Clone method either using Shallow Copy (??) calling MemberwiseClone or Deep copy (??) i.e hand coping all members. Shallow Copy Deep Copy

Microsoft Naming Conventions

Microsoft recommends following naming conventions Variables : use came case e.g. someName Method : use Pascal case e.g. SomeMethod. Also name the method by the action they perform e.g. WriteLine. Microsoft does not recommends Hungarian notation e.g. iSomeInteger or underscore e.g. Some_Integer. Coding standard: Always use this to refer to the members of current class. Never make a member field as public. Always create properties or methods to allow access to member fields.

XML to PDF in .Net

Has anyone used XALAN.Net to generate PDF from XML? It is working fine generating Pdf from FO but I am having problems if I generate FO using XslCompiledTransform to convert XML to FO. The FO file generated by using XslCompiledTransform is different compared to the file generated using XALAN in java. Both are using same style sheet. I am still scratching me head....any tip would be useful. I will post the solution if I can find any... Raj

Resources in ASP.Net

XML resouces provided for Global.asax and web forms. Resource name is webformname.aspx.resx and for Global.asaz it is Global.asax.resx You must add culture specific resources manually as there is no IDE support for this for web forms. Naming convention for culture specific resource is same as in windows application e.g. webformname.culture.resx. If these naming conventions are not followed, resource manager will not be able to find the resources. Main assembly will be deployed in \bin folder with culture specific assemblies beneith it e.g. \bin\en-US, \bin\en.