Tuesday, July 2, 2013

Built-in Data Types

Built-in Data Types

Data Types are very important in C# language before storing a value in the variable/memory it needs to be specified a type. click on every Data Type to see example.
Data Type Range
byte 0 to 255
sbyte -128 to 127
short -32,768 to 32,767
ushort 0 to 65,535
int -2,147,483,648 to 2,147,483,647
uint 0 to 4,294,967,295
long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulong 0 to 18,446,744,073,709,551,615
float -3.402823e38 to 3.402823e38
double -1.79769313486232e308 to 1.79769313486232e308
decimal -79228162514264337593543950335 to 79228162514264337593543950335
char A Unicode character.
string A string of Unicode characters.
bool True or False.
object An object.
        

byte(0 to 255)

byte x = 200; //Ok byte y = 256;//Error: Constant value '256' cannot be converted to a 'byte' byte x = 10, y = 20; byte z = x + y; //Error: Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)
 

sbyte(-128 to 127)

sbyte num = 255;//Error: Constant value '255' cannot be converted to a 'sbyte' Solution: sbyte can store -128 to 127 //You can save sbyte value in integer value directly as shown below sbyte num = 127; int tes = num;
        

short(-32,768 to 32,767)

short num = 32768;//Error: Constant value '32768' cannot be converted to a 'short' Solution: short can store -32,768 to 32,767 //You can save sbyte value in integer value directly as shown below short x = 32767, y = 32767; int tes = x + y; short z = tes;//Error: Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) short z = (short)tes;//65534 converting into short OutPut: -2 This is going cycling order.... no stop i mean positive values to negative values keep going :).
        

ushort(0 to 65,535)

ushort is Unsinged 16-bit integer ushort num = 65535;//this is good ushort num = 65536;//Error: Constant value '65536' cannot be converted to a 'ushort' Solution: ushort limits are 0 to 65,535 ushort x = 5, y = 6; ushort z = x + y;//Error: Cannot implicitly convert type 'int' to 'ushort'. An explicit conversion exists (are you missing a cast?) Solution: Addition of two ushort values will funtion with int data type so we have compile error. ushort z = (ushort)(x + y);//OK

INT (-2,147,483,648 to 2,147,483,647)

The int keyword denotes an integral type int i = 100; //Declare and initialize a variable of the type long vallong = 22; int i = vallong;//Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?) int i = (int)vallong; //Good
        

Unit(0 to 4,294,967,295)

Unit num = 123;//Ok long vallong = 123; Unit num = vallong;//Cannot implicitly convert type 'long' to 'System.Web.UI.WebControls.Unit'. Unit num = (Unit)vallong;//Ok
        

long(–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)

long is a integeral type variable is nothing but Signed 64-bit integer. long num = 4294967296;//Ok int i = 123; long j = i; //Ok
        

ulong(0 to 18,446,744,073,709,551,615)

ulong will accept Unsigned 64-bit integer values. ulong num = 9827876347898279057; unsigned value can be long or ulong but it varies depends on the value size. long vallong = 9827876347898279057; //Cannot implicitly convert type 'ulong' to 'long'. The above value is too big to be stored in long data type and use ulong to store this type of big values. ulong num = 100.0;//Error: Cannot implicitly convert type 'double' to 'ulong'. ulong num = (ulong)100.0; //Ok
        

float (-3.402823e38 to 3.402823e38)

The float keyword signifies a simple type that stores 32-bit floating-point values. Usaually the right side operator is treated as double. So specify f or F to initialize float variable as shown below float num = 1.2f; A floating-point expression can contain the following sets of values: •Positive and negative zero •Positive and negative infinity •Not-a-Number value (NaN) •The finite set of nonzero values
        

double(-1.79769313486232e308 to 1.79769313486232e308)

double is value with 15-16 digits it stores more value than float initialize the double as shown below double num = 3.0; A floating-point expression can contain the following sets of values: •Positive and negative zero. •Positive and negative infinity. •Not-a-Number value (NaN). •The finite set of nonzero values.
        

decimal(-79228162514264337593543950335 to 79228162514264337593543950335)

The decimal keyword denotes a 128-bit data type. Compared to floating-point types, the decimal type has a greater precision and a smaller range, which makes it suitable for financial and monetary calculations. The approximate range and precision for the decimal type are shown in the following table. decimal num = 100.3m;//If you want a numeric real literal to be treated as decimal, use the suffix m or M decimal num = 3.5;//Literal of type double cannot be implicitly converted to type 'decimal'; use an 'M' suffix to create a literal of this type decimal num = 3.5m;//Ok
        

char(A Unicode character.)

The char keyword is used to declare an instance of the System.Char structure that the .NET Framework uses to represent a Unicode character. The value of a Char object is a 16-bit numeric (ordinal) value. char x = 'A'; char y = 'ABC';//Error: Too many characters in character literal char x = 100;//Error: Constant value '100' cannot be converted to a 'char' char x = (char)100;//Ok but Output will be d
        

string(A string of Unicode characters.)

The string type represents a sequence of zero or more Unicode characters. string is an alias for String in the .NET Framework. string a = "hello"; string b = "h"; // Append to contents of 'b' b += "ello"; Console.WriteLine(a == b); Console.WriteLine((object)a == (object)b); This displays "True" and then "False" because the content of the strings are equivalent, but a and b do not refer to the same string instance.
        bool(True or False.)
        The bool keyword is an alias of System.Boolean. It is used to declare variables to store the Boolean values, true and false.
        

object(An object.)

The object type is an alias for System.Object in the .NET Framework. You can assign values of any type to variables of type object. All data types, predefined and user-defined, inherit from the System.Object class. The object data type is the type to and from which objects are boxed.

Wednesday, June 26, 2013

The basic functionalities of 3 - Tier or N-Tier Architecture




Presentation Layer
  •  Gathering information from the user
  • Sending the user information to the business services from processing
  • Receiving the result of the business services processing
  • Presenting those results to the user

Business Layer

  • Receiving input from the presentation tier.
  • Interacting with the data services to perform the business operations.
  • Sending the processed results to the presentation tier.

Data Service Layer

  • Storage of data
  • Retrieval of data
  • Maintenance of data
  • Integrity of data

Tuesday, June 25, 2013

Display Div Tags side by side


If you are using div tags and they display vertically.
   
    <div>
        Test 1
    </div>
    <div>
        Test 2
    </div>
    <div>
        Test 3
    </div>


OutPut:




Sometimes you want them to display horizontally or side by side. Then use style 'float' as shown below.
    <div style="float: left">
        Test 1
    </div>
    <div style="float: left">
        Test 2
    </div>
    <div style="float: left">
        Test 3
    </div>


OutPut:

Sunday, January 22, 2012

Technical Documentation Sites

1.1     Technical document sites

http://www.codeguru.com(c, c++, vc++ AND .NET)
http://www.onesmartclick.com/programming/programming.html (All)
http://www.acetheinterview.com/qanda/ (All)
http://www.techinterviews.com/ (All)
http://www.fredosaurus.com/notes-cpp/index.html (C++)
http://www.parashift.com/c++-faq-lite/ (C++)
http://cslibrary.stanford.edu/ (All)
http://williamstallings.com/Extras/OS-Notes/notes.html (OS)
http://www.cs.wisc.edu/~solomon/cs537/notes.html (OS)
http://www.winprog.org/tutorial/ (Windows)
http://ciips.ee.uwa.edu.au/~morris/Year2/PLDS210/ds_ToC.html (Data Structure)
http://hebb.cis.uoguelph.ca/~dave/343/Lectures/testing.html (Testing)
http://pweb.netcom.com/~tjensen/ptr/pointers.htm (Pointers)
http://www.intelinfo.com/Critchie (very good site)
http://www.cs.umd.edu/~mount/420/ (Java)
http://www.nist.gov/dads/ (All)
http://www.intelinfo.com/free_java_training.html (Java)
http://www.math.umd.edu/~lify/hotlink.html (All)
http://www.holub.com/goodies/rules.html (All)
http://www.apl.jhu.edu/~hall/java/ (Java, good one)
http://www.ibiblio.org/winsock/winsock-1.1/winsock.html (Win socket)
http://www.hk8.org/old%5Fweb/ (good one)
http://www.cs.cf.ac.uk/Dave/C/CE.html(C and UNIX)
http://devcentral.iticentral.com/ (All)
http://www.informit.com/ (All)
http://www.thefreecountry.com/ (All, Very good one)
http://www.tcfb.com/freetechbooks/ (All)
http://www.ibiblio.org/javafaq/javafaq.html (Java)
http://www.afu.com/javafaq.html (Java)
http://www.apl.jhu.edu/~hall/java/FAQs-and-Tutorials.html (Java)
http://www.comeaucomputing.com/techtalk/(C and C++)
http://www.memorymanagement.org (excellent)
http://resourcecenter.info/ (CAT, GRE, TOFEL, GMAT and E-Books)

1.2     Puzzle sites

http://puzzle.dse.nl/index_us.html
http://www.chlond.demon.co.uk/academic/puzzles.html
http://thinks.com/webguide/mathpuzzles.htm
http://www.eduplace.com/math/brain/
http://www.brainbashers.com/
http://barryispuzzled.com/
http://www.braingle.com/

Wednesday, November 2, 2011

Creating a Sitemap in Asp.Net

Create a New website first then right click on the project folder as shown in figure below.



Click on Add New Item, then you will see a dialogue box titled as 'Add New Item' and you see couple of installed templates as shown in below figure. In that templates if you scroll down you will see Site Map template. Select Site Map template and click on 'Add' button.


After adding SiteMap into your solution. It will generate default code as shown below. and it will be seen in your solution as shown in below figure.



<< Example on Sitemap Control in ASP.Net