M.Sc. - Master of Computer Science - Guru Jambheshwar University of Science & Technology
Questions
1. Write
short note on
a) Overriding
Method overriding in C# is a feature like the virtual function
in C++. Method overriding is a feature that allows you to invoke functions
(that have the same signatures) that belong to different classes in the same
hierarchy of inheritance using the base class reference. C# makes use of two
keywords: virtual and overrides to accomplish Method overriding. Let's
understand this through small examples.
P1.cs
class BC
{
public void Display()
{
System.Console.WriteLine("BC::Display");
}
}
class DC : BC
{
new public void Display()
{
System.Console.WriteLine("DC::Display");
}
}
class Demo
{
public static void Main()
{
BC b; b = new BC();
b.Display();
}
}
Output
BC::Display. a) Inheritance
If you run this example, you will notice that even though we have not
defined a Greet() method for the Dog class, it still knows how to greet us, because
it inherits this method from the Animal class. However, this greeting is a bit
anonymous, so let's customize it when we know which animal it is:
public class
Animal
{
public virtual void Greet()
{
Console.WriteLine("Hello, I'm some
sort of animal!");
}
}
public class
Dog : Animal
{
public override void Greet()
{
Console.WriteLine("Hello, I'm a
dog!");
}
}
}
}
class DC : BC
{
System.Console.WriteLine("DC::Display");
{
public static void Main()
b.Display();
Describe
NGWS Component and XML?
XML is short for eXtensible
Markup Language. It is a very widely used format for exchanging data, mainly
because it's easy readable for both humans and machines. If you have ever
written a website in HTML, XML will look very familiar to you, as it's
basically a stricter version of HTML. XML is made up of tags, attributes and
values and looks something like this:
<users>
<user name="John Doe"
age="42"
/>
<user name="Jane Doe"
age="39"
/>
</users>
As you can see, for a data
format, this is actually pretty easy to read, and because it's such a
widespread standard, almost every programming language has built-in functions
or classes to deal with it. C# is definitely one of them, with an entire
namespace, the System.Xml namespace, to deal with pretty much any aspect of
XML. In the following chapters, we will look into using them, both for writing
and reading XML.
C# application
C# application types include
Windows Console applications, Windows Forms applications, ASP.NET Web
applications, ASP.NET Web Service applications, Smart Device applications,
ActiveX applications, and setup and deployment applications.
Console applications use standard command-line input and output for input and
output instead of a form. Console applications use the System.IOclass for
handling input and output. You can use the class name in front of methods, such
as System.IO.Console.WriteLine(), or include ausing statement at the
start of your program. Console applications are easy to create by using Visual
Studio and other development environments that include any text editor, such as
Notepad.
Windows Applications
Windows applications have the familiar graphical user interface of Windows with
controls such as buttons and list boxes for input. The most visually stunning
Windows applications are based on Windows Presentation Foundation.
Windows Forms are used to create basic graphical user interfaces in a RAD
application environment. Windows Forms applications use classes in the System.Windows.Forms namespace.
Forms applications are easy to create using Visual Studio and other development
environments that include any text editor, such as Notepad.
Microsoft Silverlight is a cross-browser, cross-platform, and cross-device
plug-in for delivering the next generation of .NET based media experiences and
rich interactive applications for the Web. For more information, see the
Microsoft Silverlight web site.
No comments:
Post a Comment