Friday, July 19, 2013

Usage of Enum in C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

enum days
{
    monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}

namespace demo_enum
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(days.Friday);
            Console.WriteLine((int)days.Sunday);
            Console.WriteLine((int)days.Tuesday);
        }
    }
}


Output produces likes....

Friday
6
1

C# Code to generate table froms 01 - 10

C# Code to generate table froms 01 - 10 using Microsoft Visual Studio
------------------------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Table4{

class Program
{
static void Main(string[] args)
{

int prod = 0;
for (int row = 1; row <= 10; row++){

for (int col = 1; col <= 10; col++){
prod = row * col;

Console.Write(prod+"\t");}

Console.WriteLine();}

Console.WriteLine();}
}
}

.... You will get results like


Access modifiers in C#

Dot.Net Tutorials

aAccess modifiers
  • ·          Public                          Access not limited
  • ·         Private:                        Access limited to the containing of the class or a type
  • ·         Internal:                       Access limited to the containing of the program only
  • ·         Protected:                    Access limited to the containing class or types derived from the  
  •                                                                                                                    contained class
  • ·         Protected Internal:         Access limited to the program or types derived from the class


----------------------------------------------------------------------------------------------------
Example for public

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace demo_18
{
   public  class test
    {
        public int x;
        public int y;
    }
    class Program
    {
        static void Main(string[] args)
        {
            int result;
            test test1 = new test();
            test1.x = 5;
            test1.y = 10;
            result = test1.x + test1.y;
            Console.WriteLine(result);

        }
    }
}

-- In the above program, class 'test' is initialized with public access modifier, hence that class is accessed by another class i.e., program

So we would get the output as

Output:

15
... press any key to continue



 Private :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace demo_18
{
   private  class test
    {
        public int x;
        public int y;
    }
    class Program
    {
        static void Main(string[] args)
        {
            int result;
            test test1 = new test();
            test1.x = 5;
            test1.y = 10;
            result = test1.x + test1.y;
            Console.WriteLine(result);

        }
    }
}

In  above namespace, demo_18 class test is intizlised with private access modifier, where the accessibility of the test class is limited to the class test only... So above program with produce error..

" Error 1 Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal D:\Suresh Babu\demo_18\demo_18\Program.cs 8 24 demo_18"


Saturday, February 9, 2013

Netsh:
Netsh is expanded as Network shell deployed in windows NT and higher systems begining with windows 2000 operating systems. It allows local or remote configuration as an interface.

A common use of Netsh is to reset TCP/IP stack to default.


Common Usage of Netsh Commonds are:


netsh interface ip reset C:\resetlog.txt                                              <<For resettting the log file>>
netsh interface ip set address name="Local Area Connection" static 192.168.1.105 255.255.255.0 192.168.1.1 <<For setting ip address manually>>
netsh interface ip set address name="Local Area Connection" dhcp <<To attain the IP Address through DHCP>>
netsh interface ip add address local 234.234.234.234 255.255.255.0 <<To add secondary ip (Dual IP)>>

Tuesday, February 5, 2013

Date() in Javascript

Display Date in a webpage using Javascript:

<!Doctype html>
<head>
<title>Basic_webpage</title>
<body>
<h1>Today Date</h1>
<br />
<script>
document.write(Date());
</script>
</body>
<head>
</html>

--------------------------------------------------------------

It will display results as 

Today Date


Tue Feb 05 2013 16:48:32 GMT+0530 (India Standard Time)


Web Programming

Web Programming: 


                                   Construction of webpages or web content through scripting and coding using markup and programming languages is described as Web Programming. Basically, webpage can be created using HTML (Hyper text markup language) with the help of basic editors like Microsoft notepad, wordpad and contents can be categorized and can be derived with attractive features by CSS (Cascade style sheets). Images and content of webpage can be animated using Javascript, CGI, perl, ruby, php etc. PHP can be used to create webpages of both server and client side also and data of the tables or database can be stored in MySQL database management systems. 

Basic HTML Webpage

Markup (codeview)
-------------------



BASIC HTML Page: (Viewed in Google Chrome)