Archive

Archive for the ‘OOP Concept’ Category

Data Type Conversions

March 28, 2010 Leave a comment

Sometimes we have to change the data that we are using. Sometimes this change may change the value of the data or sometimes it just changes the memory space allocated by that data. This change is called data type conversion.

Data type is converted in 2 ways. They are:

  1. Implicit conversion
  2. Explicit conversion

They are described below.

Implicit conversion:

An implicit conversion converts data automatically without losing any data. Normally, data types can implicitly converted into the data types those contain more memory space.

Example:

short firstNumber = 65;

long secondNumber = firstNumber;

Explicit conversion:

An explicit conversion convert data that are automatically can’t be converted. It may converts data from bigger size to smaller size or converts data from one type into totally different type.

Example:

short firstNumber = 65;

long secondNumber = firstNumber; //Implicit conversion

short thirdNumber = (short)secondNumber; //Explicit  conversion

Console.WriteLine(thirdNumber); //outputs 65

char a = (char)firstNumber; //Explicit conversion

Console.WriteLine(a); //outputs A

We can use some built in functions those are provided with C#.

a. Convert class:

A convert class contains numerous method those can change one data type into another type. It is another implementation of explicit conversion.

Example:

int number = 65;

char character = Convert.ToChar(number); //Conversion using System’s Class

Console.WriteLine(character);   //Output: A

b. ToString() method:

A ToString() method converts any kind of data type into String type. It doesn’t change the internal value of that data.

Example:

char character = Convert.ToChar(65); //Conversion using System’s Class

string numberString = (65).ToString();

Console.WriteLine(character); //Output: A

Console.WriteLine(numberString); //Output(value is in String form): 65

Categories: ASP.NET, OOP Concept

Verbatim Characters

March 28, 2010 Leave a comment

A verbatim string is a string that is interpreted by the compiler exactly as it is written, which means that even if the string spans multiple lines or includes escape characters, these are not interpreted by the compiler and they are included with the output. The only exception is the quotation mark character, which must be escaped so that the compiler can recognize where the string ends.

string address = @”C:\Software\Books\Beginning”;

As you can see, verbatim is indicated with an ‘@’ sign at the beginning of a string.

If you want to use a quotation mark inside a verbatim string, you must escape it by using another set of quotation marks.

Example:

string greetings = @”"”Hello everyone”".said the trainer.”;

Categories: ASP.NET, OOP Concept Tags: ,

My OOP Concept

March 24, 2010 1 comment

Introduction to Object-Oriented Concepts

Although it might be a bit surprising, object-oriented software development has been around since the early 1960s. Although objects have become much more prevalent in today’s software industry, a number of software shops have yet to venture into the OO arena. It is no secret that the software industry can be slow-moving at times. It is also true that, when working systems are in place, there has to be a compelling reason to replace them. This has hindered the propagation of OO systems. There are a lot of non-OO legacy systems (that is, older systems that are already in place) that seem to be working just fine so why risk potential disaster by changing them? In most cases, you should not change them, at least not simply for the sake of change. There is nothing inherently wrong with systems written in non OO code. However, brand-new development definitely warrants the consideration of using OO technologies.

Although there has been a steady and significant growth in OO development in the past 10 years, an entirely new venue has helped catapult it further into the mainstream. The emergence of the Web has opened a brand-new arena, where much of the software development is new and mostly unencumbered by legacy concerns. Even when there are legacy concerns, there is a trend to wrap the legacy systems in object wrappers.

Here I have to share that most of the teachers in our country fail to give the real OOP concept. They focus on OOP rather than concept. For this reason we lose our imagination power. Here I suggest, there should be a prerequisite of having at least two years of field experience for being a teacher.Though we (students) have some problems. We  always dependent on teachers. Read more…

Categories: OOP Concept
Follow

Get every new post delivered to your Inbox.