Search This Blog

Wednesday, November 6, 2013

InteropServices C#

C# > InteropServices

InteropServices namespace provides members that support COM interop and platform invoke services.

The .NET Framework allows interaction with COM components, COM+ services and external type libraries.
Managed code executes under the control of the runtime.
Unmanaged code runs outside the runtime. COM components, ActiveX interfaces, and Win32 API functions are examples of unmanaged code.












Tuesday, November 5, 2013

Abstract C#

C# > Keywords > abstract

Abstract  indicates that a class is intended only to be a base class of other classes.
Abstract classes features:
  • cannot be instantiated.
  • may contain abstract methods and accessors.
  • it is not possible to modify an abstract class with the sealed modifier
  • class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Example:

    public abstract class Shape
    {
        public abstract int Area();
    }
    public class Rectangle : Shape
    {
        int x = 0;
        int y = 0;
        public Rectangle(int _x, int _y)
        {
            x = _x;
            y = _y;
        }
        public override int Area()
        {
            return x * y;
        }
    }

    Rectangle rct = new Rectangle(10, 20);
    int area = rct.Area();












Modifiers C#

C# > Modifiers

Modifiers are used to modify declarations of types and type members.




GetRandomFileName C#

C# > Files > GetRandomFileName

GetRandomFileName returns a random cryptographically string that can be used as either a folder name or a file name. GetRandomFileName does not create a file.
 
Example:
string rndFile = Path.GetRandomFileName();







Monday, November 4, 2013

Working with files in C#

C# > IO

IO allow reading and writing to files and data streams, and types that provide basic file and directory support.

Directory class

Path methods
IO
Examples:





    String Type C#

    C# > Types > String

    String type represents a sequence of Unicode characters and is a reference type.

    Methods


    Example:

    string a = "Hello";
    string b = " world";
    // Append ! to contents of b
    b += "!";
    MessageBox.Show (a + b);




    What is C#






    C# is modern, multi-paradigm,  strongly-typed, object oriented  and high level programming language.
    C# is an elegant language that enables you to build a variety of secure and robust applications that run on the .NET Framework. With C# you can create Windows client or Web applications, XML Web services, distributed components, client-server applications, database applications, etc.

    The language of C# is very easy for anyone familiar with C, C++ or Java.
    System