Singleton (ஆயிரத்தில் ஒருவன்) Design Pattern - C# - in Tamil

  Рет қаралды 8,032

VAP Student

VAP Student

Күн бұрын

"Singleton pattern ensures a class has only one instance and provides a global point of access to it."
Thumb rule:
1. Declare a private constructor for the class.
2. Declare a static member for that class.
3. Create a static method for that class.
www.vapstudent.in
Links:
NodeJs MySQL API - • API CRUD - NodeJs + Ex...
NodeJs MongoDB API - • API CRUD - NodeJS + E...
//Library.cs - Class
using System;
namespace SigletonDemo
{
public class Library
{
private static int counter = 0;
private Library()
{
counter++;
Console.WriteLine("Counter Value : " + counter.ToString());
}
public static Library objInstance;
private static readonly object mylockobject = new object(); //Multi threaded
public static Library GetInstance()
{
lock (mylockobject)
{
if (objInstance == null)
objInstance = new Library();
}
return objInstance;
}
public string getBookDetails()
{
return "The Secret - written by Rhonda Byrne.";
}
public string getBook1Details()
{
return "Thulazi - written by Balakumaran.";
}
}
}
//Book.cs - Class
using System;
namespace SigletonDemo
{
public class Book
{
static void Main(string[] args)
{
Library book = Library.GetInstance();
Library book1 = Library.GetInstance();
string sBookName = book.getBookDetails();
string sBook1Name = book1.getBook1Details();
Console.WriteLine(sBookName);
Console.WriteLine(sBook1Name);
Console.ReadLine();
}
}
}

Пікірлер: 17
@connectphanindar6956
@connectphanindar6956 3 жыл бұрын
way of explanation is good bro.. I got it finally
@VAPStudent
@VAPStudent 3 жыл бұрын
Glad it helped. Thanks for your support.
@SurendranArulbalan
@SurendranArulbalan Жыл бұрын
what are the packages we need to this demo and i create this project on web core API
@VAPStudent
@VAPStudent Жыл бұрын
Core also having inbuilt packages. you can try. I don't have sample with me.
@bharanidharank
@bharanidharank 3 жыл бұрын
Please don't use black background, it's very difficult to see
@VAPStudent
@VAPStudent 3 жыл бұрын
I will try to correct. Thanks for the info.
@thiyagarajanm7487
@thiyagarajanm7487 3 жыл бұрын
Nice..and one doubt is any other way will achieve singleton because lock key is very cost ..so please explain any other way if possible
@VAPStudent
@VAPStudent 3 жыл бұрын
Thanks for your support. Let me check and update you.
@krishna-le8zq
@krishna-le8zq 3 жыл бұрын
Itha design patterns ku playlist Iruka?
@VAPStudent
@VAPStudent 3 жыл бұрын
No. Actually planning for Oops concept play list. As of now i have completed singleton only. Thanks for your support.
@vinothkumarv9722
@vinothkumarv9722 4 жыл бұрын
can u explain this patter from js ...please
@VAPStudent
@VAPStudent 4 жыл бұрын
I am basically from C#. Anyway let me try my level best Mr.Vinothkumar.
@vinothkumarv9722
@vinothkumarv9722 4 жыл бұрын
thanks for your quick response bro... yes...please.... and please check this. is correct or not: kzbin.info/www/bejne/nIeTf3eKj6mCmaM
@nancyangelnissi
@nancyangelnissi 3 жыл бұрын
Thanks. Could understand better.
@VAPStudent
@VAPStudent 3 жыл бұрын
Welcome, Thanks for your support.
@sanocycles6642
@sanocycles6642 2 жыл бұрын
😍
@VAPStudent
@VAPStudent 2 жыл бұрын
Thankyou
Singleton Design Pattern in C# - Do it THAT way
13:15
tutorialsEU - C#
Рет қаралды 27 М.
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 17 МЛН
小丑家的感情危机!#小丑#天使#家庭
00:15
家庭搞笑日记
Рет қаралды 29 МЛН
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
路飞与唐舞桐
Рет қаралды 29 МЛН
Cucumber framework | 10 | Implementing Singleton Design Pattern | Tamil
16:53
Learn Automation Online
Рет қаралды 7 М.
Design Pattern  Intro and Singleton Demo - Tamil
36:18
Dotnet in Tamil
Рет қаралды 10 М.
Singleton Design Pattern
11:59
kudvenkat
Рет қаралды 546 М.
What is the difference between “out” and “ref” parameters?
6:50
design pattern   Factory Pattern   Tamil tutorial
6:02
GUVI
Рет қаралды 6 М.
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 17 МЛН