UrbanPro

Learn .Net Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What are Singleton classes in C sharp?

Asked by Last Modified  

15 Answers

Learn .Net

Follow 0
Answer

Please enter your answer

ASP.Net / ASP.Net MVC, C#, SQL server Expert

It is a design pattern which will help you have only single instance of an object throughout the application lifetime.
Comments

Tutor

its one of architures impemented in advanced oops cocept
Comments

Software Developer with 10 + Years of experiencing in Coding and Training.

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.
Comments

Software Developer with 10 + Years of experiencing in Coding and Training.

eg:using System; class MainApp { static void Main() { // Constructor is protected -- cannot use new Singleton s1 = Singleton.Instance(); Singleton s2 = Singleton.Instance(); if (s1 == s2) { Console.WriteLine("Objects are the same instance"); ...
read more
eg:using System; class MainApp { static void Main() { // Constructor is protected -- cannot use new Singleton s1 = Singleton.Instance(); Singleton s2 = Singleton.Instance(); if (s1 == s2) { Console.WriteLine("Objects are the same instance"); } // Wait for user Console.Read(); } } // "Singleton" class Singleton { private static Singleton instance; // Note: Constructor is 'protected' protected Singleton() { } public static Singleton Instance() { // Use 'Lazy initialization' if (instance == null) { instance = new Singleton(); } return instance; } } } read less
Comments

A singleton class is a class which can have only one object or instance of itself. The way to achieve it is to restrict the person using the class to create object through its constructor. Hence make the constructor as private. Also have a field variable of its own Type in the in the class. Expose...
read more
A singleton class is a class which can have only one object or instance of itself. The way to achieve it is to restrict the person using the class to create object through its constructor. Hence make the constructor as private. Also have a field variable of its own Type in the in the class. Expose a public static method which would when called look whether the field variable has been initialized or not. If it is not then create an instance using the private constructor and if it is then return back the already stored object o the field variable. read less
Comments

Thank You for your question Rakesh..... A singleton class has following characteristics A single private construction with no argument A static variable and the singleton class must be declared as sealed. Thank You, Team DishaaPro www.dishaapro.com
Comments

Trainer

A singleton is a class which only allows a single instance of itself to be created, and usually gives simple access to that instance. and that instance is sharing across request.
Comments

Senior .NET, Azure and MEAN Trainer 15 years experienced

Singleton Design Pattern - C# Singleton 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
Comments

B.E. Computer

A singleton class is which only allows a single instance of itself to be created, and usually gives access to that instance. Most commonly, singletons don't allow any parameters to be specified when creating the instance.
Comments

Computer Coder/Programmer

You are building an application in C#. You need a class that has only one instance, and you need to provide a global point of access to the instance. You want to be sure that your solution is efficient and that it takes advantage of the Microsoft .NET common language runtime features. You may also want...
read more
You are building an application in C#. You need a class that has only one instance, and you need to provide a global point of access to the instance. You want to be sure that your solution is efficient and that it takes advantage of the Microsoft .NET common language runtime features. You may also want to make sure that your solution is thread safe. read less
Comments

View 13 more Answers

Related Questions

What is the difference between XML and HTML?
Main Difference : HTML is used for presenting data ie it's main goal is to present data in a beautiful way, while XML is used to store and transport data ie it's main goal is to organize the data.
Aavinash
0 0
8
How can I benefit if I learn .Net Ajax?
-To reduce the burden on server -To avoid full web page submission to server so there is no full page reload and refresh. -Partial page updates that refresh only the parts of the Web page that have changed.
Aadarsh

Hi,

I have asp.net project with sql connection.I want connect database with asp.net and run the project and web config file there

In web.config: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=192.168.1.25;Initial Catalog=Login;Persist Security Info=True;User ID=sa;Password=example.com" providerName="System.Data.SqlClient"...
Fathima
What is the difference between asp.net and c#.net?
1.Csharp is best known as C#. 2.C# is a programming language used when developing Asp.net. 3.The C# programming language is specially designed for easy use in practically any purpose. 4.Asp.net...
Aadarsh

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Read CSV data using ODBC Connection
Codes to read the CSV data using ODBC Connection- Input File: File's Encoding format should be ANSI as below class Student{ public string CollegeId { get; set; } public string AdmissionDate...

Extension Methods in C#
Extension methods enables you to add methods to existing types without creating a new derived type, recompiling or otherwise modifying the original type. Extension methods are special type of static methods,...

Steps to fill drop-down value from database to view page in ASP.Net MVC Application
In simple few steps you can fill the dynamic data from database to HTML page in MVC Application Write connection string in web config file Create table related getter setter in model Fetch data...

Angular-2 Developer Training Program Syllabus
Angular2 Developer Training Program Syllabus: Introduction to Angular2. Why Angular2. Angular2 Features: Components, Services and Typescript. Angular2 Components: Templates, Modules, Services...

Difference between Abstract Class and Interface
This is probably one of the most commonly asked questions in any job interview for .Net. Before we look into the differences between the two lets find out the main features. Abstract Class By definition...

Recommended Articles

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Looking for .Net Training ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for .Net Training Classes?

The best tutors for .Net Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn .Net Training with the Best Tutors

The best Tutors for .Net Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more