was talking with few test professionals for C# automation. Team is reluctant to change from Java background to C# technologies. I have used many scripting and programming languages. There is not much variation between Java & C# at core langulage level.
Differences and similarities
Selenium script on Java & C#
Developed a sample selenium scripting using Java and ported to C#.
Reference Links
Moving to C# for Java Developers
Java Vs C#
Differences and similarities
Description | Java | C# |
---|---|---|
Program Entry Point | main(String ...args) | Main() or Main(string [] args) |
Smallest Deployment Unit | Jar | EXE/DLL, Private Assembly, Shared Assembly |
Signing | Jar Signing | Assembly Signing |
Namespace | package | namespace |
Including Classes | import | using |
Inheritance | class (extends), interface (implements) | class and interface (:) |
Visibility | private, package,protected, public | private, protected, internal,internal protected, public |
Abstract Class | abstract class X { ... } | abstract class X { ... } |
Non-Extensible Class | final class X { ... } | sealed class X { ... } |
Non-Writable Field | final | readonly |
Non-Extensible Method | final | sealed |
Constant | static final | const |
Checking Instance Type | instanceof | is |
Enums | enum, can have fields, methods and implement interfaces and are typesafe | enum, cannot have methods,fields or implement interfaces, not typesafe |
for-each construct | for (item : collection) { ... } | foreach(item in collection) { ... } |
Switch-Case | numeric types (int,float...) enums, and now strings (in Java 7) | numeric types, enums and strings |
Method Parameters | Object References are passed by Value only | Object reference are passedby Value(default), ref & out |
Variable Arguments | method(type... args) | Method(params type[] args) |
Catching Exceptions | try { ... } catch (Exception ex) {...} | try { ... } catch (Exception ex) {...} |
Meta Type | Class klass = X.class; | Type type = typeof(X); |
Meta Information | @Annotation | [Attribute] |
Static class | Simulated by private Ctor and static methods | Static class and ctor with static methods |
Properties | getProperty(),setProperty() | Property { get; set; } compiler generated get_Property() and set_Property() methods |
Selenium script on Java & C#
Developed a sample selenium scripting using Java and ported to C#.
Reference Links
Moving to C# for Java Developers
Java Vs C#