Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 35736

C# Tip’s and Tricks

$
0
0

 

logoaspnet 

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

Java

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

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

C#

   1: class Studnet 
   2: {
   3:  
   4: public String _name {set; get;}
   5:  
   6: public Student (String Name)
   7: {
   8:     _name = Name;
   9: }
  10:  
  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


Viewing all articles
Browse latest Browse all 35736

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>