Home

IBM 483 Tips | SCJEA Exam Tips | About Me | Code Review Tool | SmartApp | JAAS - LDAP | MVC Frameworks | C# - Variations from Java | DotNet Best Practices | Interesting Links
Architect's Corner
C# - Variations from Java

My notes which has variations and parallels to java language.


import : using
Console : System
main method can return int or void
struct is of value type whereas class is a reference type
bool : boolean in java
string : using System ( works like a value type)
Array.Sort, Array.Reverse, Length
boxing : converting value type to a reference type
unboxing : reverse process of boxing
internal modifier : variable can be accessed from the current program
protected internal : from the current program and the sub types
readonly modifier : like final in java
const : similar to readonly  field
is : check whether an object is compatible with a specific type
sizeof : size in bytes
typeof :
foreach : iterate through each item in a container class that supports IEnumerable class
using Block statement
out keyword : you can pass a variable declared but uninitialized to a method with this prefix
using Directive : package system
namespace alias : ex : using test=Check.Test

creation of dll   : csc /t:library
linking to dll : csc /r:x.dll
xml documentation: starts with ///  <summary>  <returns> <param>
generating doc : csc /doc:x.xml
properties : public static int value {  get { } set { } }  
virtual, new, override, access modifiers base keyword

static constructors
const: you should assign values when this variable is declared
readonly: you can assign values inside a constructor only
this: similar to java (for calling other constructor from a constructor)
base constructors
Finalize : similar to java

destructor : ~className
Dispose,Close method used in conjunction with Finalize
IDisposable
operator overloading supported
interfaces : similar to java ( additional : defining property methods)
try catch finally block similar to java (additional default catch block
which takes care of exception thrown by other managed code (languages)
delegates are like function pointers
c# preprocessor directives : define, undef, if , elif, else, endif,warning,error,
region,endregion, line,
Attributes : similar to preprocessor directives
     Conditional, DllImport, Obsolete
unsafe block : for pointers
pointer syntax similar to c++
ReferenceEquals on the object checks for equality of checks
Regular expression support in C#, System.Text.RegularExpressions
System.Collections : similar to java collections
custom Attributes
reflection : Type, typeOf, GetMethods returns MethodInfo
lock block : similar to synchronized block
 
 
 
 
 
 

 

This is rawnotes... Obviously you need to lookup some book for more details