Thursday, 31 December 2015
Monday, 14 December 2015
IQS
Sorting Program using C#
In this program, just sort the numbers without using any methods.....
To open the Console application and write the code
namespace SortingNos
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter Numbers :");
int[] arr = new int[5];
string arr1 = "";
for (int i = 0; i < 5; i++)
{
arr1 = Console.ReadLine();
arr[i] = Convert.ToInt32(arr1);
}
int a, b, temp = 0;
Console.WriteLine();
for (a = 0; a < arr.Length; a++)
{
for(b=a+1;b< arr.Length;b++)
{
if (arr[a] > arr[b])
{
temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
}
Console.WriteLine(arr[a]);
}
Console.ReadLine();
}
}
}
run the program....The sample output is
Enter Numbers :
50
23
10
4
7
Below are The sorted numbers
4
7
10
23
50
In this program, just sort the numbers without using any methods.....
To open the Console application and write the code
namespace SortingNos
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter Numbers :");
int[] arr = new int[5];
string arr1 = "";
for (int i = 0; i < 5; i++)
{
arr1 = Console.ReadLine();
arr[i] = Convert.ToInt32(arr1);
}
int a, b, temp = 0;
Console.WriteLine();
for (a = 0; a < arr.Length; a++)
{
for(b=a+1;b< arr.Length;b++)
{
if (arr[a] > arr[b])
{
temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
}
Console.WriteLine(arr[a]);
}
Console.ReadLine();
}
}
}
run the program....The sample output is
Enter Numbers :
50
23
10
4
7
Below are The sorted numbers
4
7
10
23
50
Difference between LINQ to SQL and Entity Framework
- LINQ to SQL allow you to query and modify SQL Server database by using LINQ syntax. Entity framework is a great ORM shipped by Microsoft which allow you to query and modify RDBMS like SQL Server, Oracle, DB2 and MySQL etc. by using LINQ syntax. Today, EF is widely used by each and every .NET application to query to database. The difference between LINQ to SQL and EF is given below.
LINQ to SQL
Entity Framework
It only works with SQL Server Database.
It can works with various databases like Oracle, DB2, MYSQL, SQL Server etc.
It generates a .dbml to maintain the relation
It generates an .edmx files initially. The relation is maintained using 3 different files .csdl, .msl and .ssdl
It has not support for complex type.
It has support for complex type.
It cannot generate database from model.
It can generate database from model.
It allows only one to one mapping between the entity classes and the relational tables /views.
It allows one-to-one, one-to-many & many-to-many mappings between the Entity classes and the relational tables /views
It allows you to query data using DataContext.
It allows you to query data using EntitySQL, ObjectContext, DbContext.
It provides a tightly coupled approach.
It provides a loosely coupled approach. Since its code first approach allow you to use Dependency Injection pattern which make it loosely coupled .
It can be used for rapid application development only with SQL Server.
It can be used for rapid application development with RDBMS like SQL Server, Oracle, DB2 and MySQL etc.
Singleton Design Pattern - C#
ngleton pattern falls under Creational Pattern of Gang of Four (GOF) Design Patterns in .Net. It is pattern is one of the simplest design patterns. This pattern ensures that a class has only one instance. In this article, I would like share what is Singleton pattern and how is it work?
What is Singleton Pattern?
Singleton pattern is one of the simplest design patterns. This pattern ensures that a class has only one instance and provides a global point of access to it.
Singleton Pattern - UML Diagram & Implementation
The UML class diagram for the implementation of the Singleton design pattern is given below:
The classes, and objects in the above UML class diagram are as follows:
Singleton
This is a class which is responsible for creating and maintaining its own unique instance.
C# - Implementation Code
- //eager initialization of singleton
- public class Singleton
- {
- private static Singleton instance = new Singleton();
- private Singleton() { }
- public static Singleton GetInstance
- {
- get
- {
- return instance;
- }
- }
- }
- ////lazy initialization of singleton
- public class Singleton
- {
- private static Singleton instance = null;
- private Singleton() { }
- public static Singleton GetInstance
- {
- get
- {
- if (instance == null)
- instance = new Singleton();
- return instance;
- }
- }
- }
- ////Thread-safe (Double-checked Locking) initialization of singleton
- public class Singleton
- {
- private static Singleton instance = null;
- private Singleton() { }
- private static object lockThis = new object();
- public static Singleton GetInstance
- {
- get
- {
- lock (lockThis)
- {
- if (instance == null)
- instance = new Singleton();
- return instance;
- }
- }
- }
- }
Singleton Pattern - Example
Who is what?
The classes and objects in the above class diagram can be identified as follows:
- Singleton - Singleton class
C# - Sample Code
- /// <summary>
- /// The 'Singleton' class
- /// </summary>
- public class Singleton
- {
- // .NET guarantees thread safety for static initialization
- private static Singleton instance = null;
- private string Name{get;set;}
- private string IP{get;set;}
- private Singleton()
- {
- //To DO: Remove below line
- Console.WriteLine("Singleton Intance");
- Name = "Server1";
- IP = "192.168.1.23";
- }
- // Lock synchronization object
- private static object syncLock = new object();
- public static Singleton Instance
- {
- get
- {
- // Support multithreaded applications through
- // 'Double checked locking' pattern which (once
- // the instance exists) avoids locking each
- // time the method is invoked
- lock (syncLock)
- {
- if (Singleton.instance == null)
- Singleton.instance = new Singleton();
- return Singleton.instance;
- }
- }
- }
- public void Show()
- {
- Console.WriteLine("Server Information is : Name={0} & IP={1}", IP, Name);
- }
- }
- /// <summary>
- /// Singleton Pattern Demo
- /// </summary>
- ///
- class Program
- {
- static void Main(string[] args)
- {
- Singleton.Instance.Show();
- Singleton.Instance.Show();
- Console.ReadKey();
- }
- }
Singleton Pattern Demo - Output
When to use it?
- Exactly one instance of a class is required.
- Controlled access to a single object is necessary.
Friday, 11 December 2015
mvc
lifecycle in mvc
cdn in mvc
use of controller
what is routing
request flow in mvc
what is ioc in mvc
how to implement Ajax in mvc
Bundling in MVC and what is the use?
Dependency Injection in ASP.NET MVC 4 using Unity IoC Container
http://challlengebrains.blogspot.in
cdn in mvc
use of controller
what is routing
request flow in mvc
what is ioc in mvc
how to implement Ajax in mvc
Bundling in MVC and what is the use?
Dependency Injection in ASP.NET MVC 4 using Unity IoC Container
http://challlengebrains.blogspot.in
Thursday, 10 December 2015
iqs
how will you maintain state in mvc
filters in mvc withexplain?
how will you disabled session in particular control
difference between razor and aspx engine
Partial view in mvc
exception handling in mvc
construcor types
difference between virtual na dnew
difference between readonly and constent
difference between interfaces and abstract class
what is abstract class?
what is a static class with all concepts?
access specifiers?protected and internal
extension method?what is the use
without using static can we do extension method
var key word?
difference between new and virtual?
range validator in asp.net
validation controls
diff bwt javascript and jquery
calling ajax methods in javascript
what is output in javascript
var i=1+2+"3"
ans::33
indexes in sql
what is temp table and CTE?
filters in mvc withexplain?
how will you disabled session in particular control
difference between razor and aspx engine
Partial view in mvc
exception handling in mvc
construcor types
difference between virtual na dnew
difference between readonly and constent
difference between interfaces and abstract class
what is abstract class?
what is a static class with all concepts?
access specifiers?protected and internal
extension method?what is the use
without using static can we do extension method
var key word?
difference between new and virtual?
range validator in asp.net
validation controls
diff bwt javascript and jquery
calling ajax methods in javascript
what is output in javascript
var i=1+2+"3"
ans::33
indexes in sql
what is temp table and CTE?
Friday, 4 December 2015
wcf
Ø What are the important principles of SOA (Service oriented
Architecture)?
Ø
What are ends, contract,
address, and bindings?
Ø
Which specifications does
WCF follow?
Ø
What are the main
components of WCF?
Ø
Explain how Ends, Contract,
Address, and Bindings are done in WCF?
Ø
What is a service class?
Ø
What is a service contract,
operation contract and Data Contract?
Ø
What are the various ways
of hosting a WCF service?
Ø
How do we host a WCF
service in IIS?
Ø
What are the advantages of
hosting WCF Services in IIS as compared to self-hosting?
Ø
What are the major
differences between services and Web services?
Ø
What is the difference WCF
and Web services?
Ø
What are different bindings
supported by WCF?
Ø
Which are the various
programming approaches for WCF?
Ø
What is one-way operation?
Ø
Can you explain duplex
contracts in WCF?
Ø
How can we host a service
on two different protocols on a single server?
Ø
How can we use MSMQ
bindings in WCF?
Can you explain
transactions in WCF?
Ø
What different transaction
isolation levels provided in WCF?
Ø
Can we do transactions
using MSMQ?
Ø
Can we have two-way
communications in MSMQ?
Ø
What are Volatile queues?
Ø
What are Dead letter
queues?
Ø
What is a poison message?
Subscribe to:
Posts (Atom)