Multi-Threading Program

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

namespace MultiTheadingAbort  
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread th = new Thread(writey);
            if (th.IsAlive)
            {
                th.Start();
                th.Abort();
            }
            for (int i = 0; i <= 10;i++ )
            {
                Console.WriteLine("hello");
            }
            Console.Read();
        }

        private static void writey()
        {
            for (int i = 0; i <= 9;i++ )
            {
                Console.WriteLine("kul");
            }
        }

    }
}

Share:

Threading Program

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

namespace mThreading
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread th = new Thread(writey);
            th.Start();
            for (int i = 0; i <= 10;i++ )
            {
                Console.WriteLine("hello");
            }
            Console.Read();
        }
        private static void writey()
        {
            for (int i = 0; i <= 9;i++ )
            {
                Console.WriteLine("world");
            }
        }
    }
}

Share:

What is Copy Constructor in C#? Example.

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

namespace CopyConstructor
{
    class Program
    {
        static void Main(string[] args)
        {
            Test T = new Test(10,20);
            T.Print();
            Console.Read();
        }
    }
    class Test

    {
        int A, B;
        public Test(int X,int Y)
        {
            A = X;
            B = Y;
        }
        public Test(Test T)
        {
           A = T.A;
           B = T.B;
        }
        public void Print()
        {
            Console.Write("A={0} and B={1}",A,B);
        }
 
    }
}

Share:

Parameterized Constructor

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

namespace ParameterizedConstructorExamples
{
    class Program
    {
        static void Main(string[] args)
        {
            Test T = new Test(10,20);
            T.Print();
            Console.Read();
        }
    }
    class Test
    {
        int A, B;
        public Test(int X, int Y)
        {
            A = X;
            B = Y;
        }
        public void Print()
        {
            Console.Write("A ={0} and B={1}",A,B);
        }
    }
}

Share:

How to find distinct element from multiple time's coming elements in the Array in C#

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

namespace FromMultipleElementsFindDistinctEach
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ar = new int [] {1,1,1,2,2,2,2,2,3,4,4};
            var distinct = new HashSet<int>(ar);
            foreach (int i in distinct)
            {
                Console.Write(i+",");
            }
            Console.Read();
        }
    }
}

Share:

User valid or none valid procedure in SQL Server

create database zz
-create table
create table users (id int identity(1,1),username varchar(50),password
varchar(50))
--insert values in table
insert into users values('kul',123)
--create procedure
create proc getoutput
(
@UserName varchar(50),
@password varchar(50),
@UName varchar(50) OUTPUT,
@Pword varchar(50) OUTPUT
)
as
Begin
IF EXISTS(Select * FROM users WHERE UserName = @UserName AND Password = @password)
Begin
set @UName=@UserName
set @Pword=@password
end
else
begin
print 'You are not a valid user.'
end
End
--call procedure
declare @UsName varchar(50);
declare @pass varchar(50);
exec getoutput 'kul','1223' ,@UName=@UsName output,@Pword=@pass output
print @UsName
print @pass

        
Share:

Monday, 31 August 2015

Multi-Threading Program

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

namespace MultiTheadingAbort  
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread th = new Thread(writey);
            if (th.IsAlive)
            {
                th.Start();
                th.Abort();
            }
            for (int i = 0; i <= 10;i++ )
            {
                Console.WriteLine("hello");
            }
            Console.Read();
        }

        private static void writey()
        {
            for (int i = 0; i <= 9;i++ )
            {
                Console.WriteLine("kul");
            }
        }

    }
}

Threading Program

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

namespace mThreading
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread th = new Thread(writey);
            th.Start();
            for (int i = 0; i <= 10;i++ )
            {
                Console.WriteLine("hello");
            }
            Console.Read();
        }
        private static void writey()
        {
            for (int i = 0; i <= 9;i++ )
            {
                Console.WriteLine("world");
            }
        }
    }
}

What is Copy Constructor in C#? Example.

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

namespace CopyConstructor
{
    class Program
    {
        static void Main(string[] args)
        {
            Test T = new Test(10,20);
            T.Print();
            Console.Read();
        }
    }
    class Test

    {
        int A, B;
        public Test(int X,int Y)
        {
            A = X;
            B = Y;
        }
        public Test(Test T)
        {
           A = T.A;
           B = T.B;
        }
        public void Print()
        {
            Console.Write("A={0} and B={1}",A,B);
        }
 
    }
}

Parameterized Constructor

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

namespace ParameterizedConstructorExamples
{
    class Program
    {
        static void Main(string[] args)
        {
            Test T = new Test(10,20);
            T.Print();
            Console.Read();
        }
    }
    class Test
    {
        int A, B;
        public Test(int X, int Y)
        {
            A = X;
            B = Y;
        }
        public void Print()
        {
            Console.Write("A ={0} and B={1}",A,B);
        }
    }
}

How to find distinct element from multiple time's coming elements in the Array in C#

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

namespace FromMultipleElementsFindDistinctEach
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ar = new int [] {1,1,1,2,2,2,2,2,3,4,4};
            var distinct = new HashSet<int>(ar);
            foreach (int i in distinct)
            {
                Console.Write(i+",");
            }
            Console.Read();
        }
    }
}

User valid or none valid procedure in SQL Server

create database zz
-create table
create table users (id int identity(1,1),username varchar(50),password
varchar(50))
--insert values in table
insert into users values('kul',123)
--create procedure
create proc getoutput
(
@UserName varchar(50),
@password varchar(50),
@UName varchar(50) OUTPUT,
@Pword varchar(50) OUTPUT
)
as
Begin
IF EXISTS(Select * FROM users WHERE UserName = @UserName AND Password = @password)
Begin
set @UName=@UserName
set @Pword=@password
end
else
begin
print 'You are not a valid user.'
end
End
--call procedure
declare @UsName varchar(50);
declare @pass varchar(50);
exec getoutput 'kul','1223' ,@UName=@UsName output,@Pword=@pass output
print @UsName
print @pass

        

Popular

Total Pageviews

Archive