using System;
class abc
{
public static void Main()
{
int [,]matrix1=new int[3,3]
{{4,5,7},
{2,4,6},
{1,5,7},
};
int [,]matrix2=new int[3,3]
{
{2,5,1},
{1,2,4},
{3,5,7},
};
int [,]matrix3=new int[3,3];
for(int row=0;row<=2;row++)
{
for(int col=0;col<=2;col++)
{
matrix3[row,col]=matrix1[row,0]*matrix2[0,col]+matrix1[row,1]*matrix2[1,col]+matrix1[row,2]*matrix2[2,col];
}
}
Console.WriteLine(" Resultant Matrix is ");
for(int row=0;row<=2;row++)
{for(int col=0;col<=2;col++)
{
Console.Write(matrix3[row,col]+" ,");
}
Console.WriteLine("\n");
}
}
About Me
Tuesday, November 30, 2010
Thursday, November 25, 2010
How to create object in C# programming ?
First of all I want to say sorry to all bcoz I m writting this blog after a long time.
Today I want write how to create object(instance) in programming language.
In last post i have written what is object?
For creating object we have to write following line of code
classname objectname=new classname();
After writting this code we can call method or access variable of that class
here classname refers name of class .
and object name refers name of object.
new is a key word that allocates memory for the object.
to clear understand see following code below.
class ABC
{
public static void Main()
{
ABC obj=new ABC(); //here obj is actual object.
}
}
To call a method in C# and how to access variable in C# we will learn next day.
Today I want write how to create object(instance) in programming language.
In last post i have written what is object?
For creating object we have to write following line of code
classname objectname=new classname();
After writting this code we can call method or access variable of that class
here classname refers name of class .
and object name refers name of object.
new is a key word that allocates memory for the object.
to clear understand see following code below.
class ABC
{
public static void Main()
{
ABC obj=new ABC(); //here obj is actual object.
}
}
To call a method in C# and how to access variable in C# we will learn next day.
Subscribe to:
Posts (Atom)