In C# there is the concept of namespaces, which (roughly) correlates to a package in Java, although in Java the naming convention matches the folder structure of the compiled .jar file whereas the C# namespace does not have to. Similarly, there is no hard and fast naming rule in C# class-file relationships, but most conventions follow this trend for ease of use. One big difference is the way get__ and set__ methods are written in C# - often properties are used instead. Another difference in syntax (but not really behaviour) is the way in which interfaces are implemented or base classes extended.
Your Java example might look something like this in C#:
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.Common;
namespace Example
{
// the : indicates extends and/or implements
public class MyFrame: Form
{
private string name = "C# the son of Java";
// the : here indicates that the constructor "inherits" the base class constructor
public MyFrame() : base()
{
// ...
}
// C# convention - methods and properties start with capital letter
// instead of Java's camel case of lowercase first letter but capitalises second word, third word etc
public void PrintMe(string name)
{
//...
}
private string GetName()
{
// although this is legal, in C# you would probably use a property (see below)
return this.name;
}
// Property - outside this class use MyFrame.Name to access the name variable.
public string Name
{
get
{
return this.name;
} …