Thursday, 4 December 2014
C# Window Programming
A programmer and Founder of Girfa
IT Services, working from 2009.At Starting computer teaching was my full-time job but after 10 years of teaching I chose to programming as a full-time job and teaching become part-time. In real life, I am very lazy and I made it my coding style I always try to make a reusable component that’s my USP for programming which saves my time and extra working both.
Thursday, 27 November 2014
C# Basic Concept and Tutorial
Static Classes
A class can be declared static, which indicates
that it contains only static members. It is not possible to use the new keyword
to create instances of a static class. Static classes are loaded automatically
by the .NET Framework common language runtime (CLR) when the program or
namespace that contains the class is loaded.
Use
a static class to contain methods that are not associated with a particular
object. For example, it is a common requirement to create a set of methods that
do not act on instance data and are not associated to a specific object in your
code. You could use a static class to hold those methods.
Following
are the main features of a static class:
·
They only contain static
members.
·
They cannot be
instantiated.
·
They are sealed.
·
They cannot contain
Instance Constructors (C# Programming Guide).
Creating
a static class is therefore basically the same as creating a class that
contains only static members and a private constructor. A private constructor
prevents the class from being instantiated.
The
advantage of using a static class is that the compiler can check to make sure
that no instance members are accidentally added. The compiler will guarantee
that instances of this class cannot be created.
Static
classes are sealed and therefore cannot be inherited. They cannot inherit from
any class except Object. Static classes cannot contain an instance constructor;
however, they can have a static constructor. For more information
Static Members
A
static method, field, property, or event is callable on a class even when no
instance of the class has been created. If any instances of the class are
created, they cannot be used to access the static member. Only one copy of
static fields and events exists, and static methods and properties can only
access static fields and static events. Static members are often used to
represent data or calculations that do not change in response to object state;
for example, a math library might contain static methods for calculating sine
and cosine.
Static
methods can be overloaded but not overridden.
Static
class members are declared by using the static keyword before the return type of the member, for example:
A programmer and Founder of Girfa
IT Services, working from 2009.At Starting computer teaching was my full-time job but after 10 years of teaching I chose to programming as a full-time job and teaching become part-time. In real life, I am very lazy and I made it my coding style I always try to make a reusable component that’s my USP for programming which saves my time and extra working both.
Wednesday, 26 November 2014
C# Programming Practical Questions
Question : Write a program which accept input of full path of a file and produce following output?
Input : C:/Users/Public/Pictures/SamplePictures/Desert.jpg
Output :
Extension : jpg
File Name : Desert
Path : C:/Users/Public/Pictures/SamplePictures
Solution :
import java.util.*;
public class Main
{
public static void main(String[] args)
{
String str;
Scanner sc=new Scanner(System.in);
System.out.print("Enter your name>> ");
str=sc.nextLine();
int ep,sp;
ep=str.indexOf(".");
sp=str.lastIndexOf("\\");
System.out.print("\nExtention is "+str.substring(ep+1,str.length()));
System.out.println("\nFile Name is "+str.substring(sp+1,ep));
System.out.println("\npath is "+str.substring(0,sp));
}
}
A programmer and Founder of Girfa
IT Services, working from 2009.At Starting computer teaching was my full-time job but after 10 years of teaching I chose to programming as a full-time job and teaching become part-time. In real life, I am very lazy and I made it my coding style I always try to make a reusable component that’s my USP for programming which saves my time and extra working both.
C# Tutorial and Notes
Static Classes
A class can be declared static, which indicates
that it contains only static members. It is not possible to use the new keyword
to create instances of a static class. Static classes are loaded automatically
by the .NET Framework common language runtime (CLR) when the program or
namespace that contains the class is loaded.
Use
a static class to contain methods that are not associated with a particular
object. For example, it is a common requirement to create a set of methods that
do not act on instance data and are not associated to a specific object in your
code. You could use a static class to hold those methods.
Following
are the main features of a static class:
·
They only contain static
members.
·
They cannot be
instantiated.
·
They are sealed.
·
They cannot contain
Instance Constructors (C# Programming Guide).
Creating
a static class is therefore basically the same as creating a class that
contains only static members and a private constructor. A private constructor
prevents the class from being instantiated.
The
advantage of using a static class is that the compiler can check to make sure
that no instance members are accidentally added. The compiler will guarantee
that instances of this class cannot be created.
Static
classes are sealed and therefore cannot be inherited. They cannot inherit from
any class except Object. Static classes cannot contain an instance constructor;
however, they can have a static constructor. For more information
Static Members
A
static method, field, property, or event is callable on a class even when no
instance of the class has been created. If any instances of the class are
created, they cannot be used to access the static member. Only one copy of
static fields and events exists, and static methods and properties can only
access static fields and static events. Static members are often used to
represent data or calculations that do not change in response to object state;
for example, a math library might contain static methods for calculating sine
and cosine.
Static
methods can be overloaded but not overridden.
Static
class members are declared by using the static keyword before the return type of the member, for example:
A programmer and Founder of Girfa
IT Services, working from 2009.At Starting computer teaching was my full-time job but after 10 years of teaching I chose to programming as a full-time job and teaching become part-time. In real life, I am very lazy and I made it my coding style I always try to make a reusable component that’s my USP for programming which saves my time and extra working both.
Subscribe to:
Posts (Atom)