Sunday, July 10, 2016

Comparison of C# and Java for testers

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

DescriptionJavaC#
Program Entry Pointmain(String ...args) Main() or Main(string [] args)
Smallest Deployment UnitJarEXE/DLL, Private Assembly, Shared Assembly
SigningJar SigningAssembly Signing
Namespacepackage namespace
Including Classesimportusing
Inheritanceclass (extends), interface (implements)class and interface (:)
Visibilityprivate, package,protected, publicprivate, protected, internal,internal protected, public
Abstract Classabstract class X { ... }abstract class X { ... }
Non-Extensible Classfinal class X { ... }sealed class X { ... }
Non-Writable Fieldfinalreadonly
Non-Extensible Methodfinalsealed
Constantstatic finalconst
Checking Instance Typeinstanceofis
Enumsenum, can have fields, methods and implement interfaces and are typesafeenum, cannot have methods,fields or implement interfaces, not typesafe
for-each constructfor (item : collection)
{ ... }
foreach(item in collection)
{ ... }
Switch-Casenumeric types (int,float...) enums, and now strings (in Java 7)numeric types, enums and strings
Method ParametersObject References are passed by Value onlyObject reference are passedby Value(default), ref & out
Variable Argumentsmethod(type... args)Method(params type[] args)
Catching Exceptionstry { ... } catch (Exception ex) {...}try { ... } catch (Exception ex) {...}
Meta TypeClass klass = X.class;Type type = typeof(X);
Meta Information@Annotation[Attribute]
Static classSimulated by private Ctor and static methodsStatic class and ctor with static methods
PropertiesgetProperty(),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#

13 comments:

sathya said...

Superb explanation & it's too clear to understand the concept as well, keep sharing admin with some updated information with right examples.Keep update more posts.

Software testing Training in Chennai

Unknown said...

Coded ui Training in Chennai by Vishwa
Hi, Reach Mr.Vishwa for Best Selenium and Coded UI Training in Chennai with real time project assistance. This people will teach everything from the basics up to advanced level scenarios from frameworks.
I learned from Mr.Vishwa and Raj they are very good automation people for Selenium Frameworks. After joined with them I learned many things and now I am writing automation scripts in own project. Vishwa 9003085882
Coded UI training in chennai

Unknown said...

Java is partially compiled and partially interpreted language. That gives us the opportunity to write a program - like one above - only once, and compile it for JVM. The environment where you want to run it should now have a JRE of it’s own, to which your program will talk.

java training in chennai

ICS Cyber Security said...

There are many flavours of programming all requiring slightly different variations in capability. Being able to think in the abstract and visualize the whole as one builds the necessary assembly of code, whether objects or created entities is a key requirement, programming skills is actually in the legacy systems which will hang around for another 50 years and that requires real skill and ability.

Secure software development

Sowmiya said...

This blog is very well good so please say about those things it is very well useful too, so please say about many interesting facts.

Web Design Company in Chennai

Aasha said...


This blog explains the details about changing the ways of doing that business. That is understand well and doing some different process. Provides he best output of others. Thanks for this blog.
Digital Marketing Company in Chennai
SEO Company in Chennai

deeksha said...

This blog is very well interesting, very well impressive and very well done so please increased the passion it will be helpful for me.

Digital Marketing Company in Chennai

Aasha said...

Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
SEO Company in India
Digital Marketing Company in India

Unknown said...

Thanks for sharing article like this. The way you have stated everything above is quite awesome. Keep blogging like this. Thanks.
Selenium Training in Chennai

Unknown said...

thanks for giving absolute way to achieve career goals. nice and well guidance to me. keep share more things.
New Zealand education Consultants in Chennai

Sri akshaya said...


The way you have stated everything above is quite awesome. Keep blogging like this. Thanks a lot

Digital Marketing Company in Chennai

deeksha said...

I am really searching for this kind of information, as well as i came to know many things. so please update the latest information, it may be useful for me.

Digital Marketing Company in Chennai

Unknown said...

Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle.
Best Dental Clinic In Vellore