C# Tip’s and Tricks



Are you interested in developing apps for Windows phone and Windows 8 and you already got the skills to code in Java.

After few years developing in Java, I have finally decided to switch to C# with .net Framework. There are several reasons for this decision which I will going to explain in this series.

Every time I talk to students on creating  apps, I kept hearing the same thing which they don’t know how to code in C#.

This is why I'm going to show some tips and trick’s to code in C# from a Java projective .

Take in mind that you can actually develop an app for Windows 8  in either C# , C++ or even JavaScript and HTML5. Learn more here

Check out this useful book that I read by Rob Miles called C Sharp from Java Orange Book.that shows you how to code C# from a Java projective.

Keep tuned as I will be posting Tip’s biweekly every Thursday.

Tip #1

Simple Class


 1: class Student{
 2: private string name;
 4: public Student (String Name)
 5: {
 6:     name = Name;
 7: }
 9: public void setname (String Name)  //Set
 10: {
 11:     name = Name;
 12: }
 14: public string getname () //Get
 15: {
 16:     return name;
 17: }
 19: }

P.S If you tried to copy this code to a C# app, It will totally work.


 1: class Studnet 
 2: {
 4: public string name {set; get;}
 6: public Student (string Name)
 7: {
 8:     name = Name;
 9: }
 11: }

As you can see, I needed only 4 lines of code in C# where as 9 in Java.

One last thing , If you started coding in C#  and you got some tips that you would like to share , let me know and maybe we can share your experience.You can reach me at  t-ramdeb@microsoft.com

Comments (1)

  1. Chris says:

    Well, your code isn't exactly the same. To the outside it is, but internally there is a accessor to a private field needed to fit exactly.

    private string name;

    public string Name { get { return name; } set { name = value; } }

Skip to main content