No video

Singleton Design Pattern in C# - Do it THAT way

  Рет қаралды 25,497

tutorialsEU - C#

tutorialsEU - C#

Күн бұрын

🚀 C# Progress Academy - Become a senior C# developer: academy.tutori...
🏃‍♂️ Learn HOW TO work with SINGLETONS in C# with these easy steps!
We'll make sure to make a Developer out of you in no time!
So, what is C#?
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in .NET. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers. This tour provides an overview of the major components of the language in C# 8 and earlier. If you want to explore the language through interactive examples, try the introduction to C# tutorials.
And what about Singletons?
In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to a singular instance. One of the well-known "Gang of Four" design patterns, which describe how to solve recurring problems in object-oriented software, the pattern is useful when exactly one object is needed to coordinate actions across a system.
More specifically, the singleton pattern allows objects to:
Ensure they only have one instance
Provide easy access to that instance
Control their instantiation (for example, hiding the constructors of a class)
To learn more, make sure to watch the video, and we promise you that you'll become a C# developer in no time! Have fun!
#csharp #dotnet #coding #tutorial #learn #microsoft #net #singleton #pattern #designpatterns
TAGS
dotnet,csharp,dotnet core,.net core tutorial,.net core,.net,c#,Tutorials,Tutorial,Programming,Course,Learn,Step by step,guide,programmer,core,code,c sharp,sharp,net6,6.0,.net framework,programming,visual studio,programming for beginners,coding,how to code,dot net,c# programming,tim corey,software development,singleton,gang of four,singleton design pattern,design pattern,design patterns,data structures,java,dynamic programming,singleton in c#,pattern
tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x
Android: / @tutorialseuandroid
C#: / @tutorialseuc
Unity: / @tutorialseuunity
Facebook: / tutorialseu-1093802040...
LinkedIn: / tutorialseu
Discord: / discord

Пікірлер: 32
@tutorialsEUC
@tutorialsEUC Жыл бұрын
🚀 C# Progress Academy - Become a senior C# developer: academy.tutorials.eu/p/csharp-progress-academy
@superkfc5410
@superkfc5410 Жыл бұрын
This is the best Singleton tutorial i've come across. Great stuff!
@rodolfoa.calvojaubert9953
@rodolfoa.calvojaubert9953 10 ай бұрын
Nice tut, but I must say that it does not explain when and why I should use such pattern, I think it would nice to have something like that but more orientated to a real scenarios because this is too simple
@abyandev8571
@abyandev8571 Жыл бұрын
easy to follow. Best Tutorial ❤
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Glad you think so!
@saecula2391
@saecula2391 Жыл бұрын
sehr schön erklärt @ 08:42 .. lock gab es auch schon in delphi 5, eine sehr nützliche Funktion um gleichzeitige threads doch noch unter Kontrolle zu bringen *g
@codewithsakti8197
@codewithsakti8197 16 күн бұрын
Thanks ..
@andreysemykin5879
@andreysemykin5879 5 ай бұрын
Instead of manually managing a lifetime for a service, using static etc it should be done via DI container and in the real world nobody does it the way in the video.
@bhaskerreddy88
@bhaskerreddy88 2 ай бұрын
I have one dought. What is the use of sealed keyword when the constructer is already private?
@MarinaMarina-fr8ex
@MarinaMarina-fr8ex 8 ай бұрын
This is great tutorial. Can you please add more videos for other design patterns like strategy, observer, facade etc?
@NivedyaSusil
@NivedyaSusil 3 ай бұрын
Thanks ! Pls do videos on other design patterns as well
@JohnEBoldt
@JohnEBoldt 3 ай бұрын
How about this approach? namespace SingletonConsole { public sealed class UploadService { private static UploadService _uploadService; private UploadService() { } static UploadService() { _uploadService = new UploadService(); } public static UploadService Instance() { return _uploadService; } } } Static constructors in C# are thread safe, so this will guarantee that _uploadService is initiated only the first time UploadService is referenced.
@Special_221
@Special_221 6 ай бұрын
Excellent demonstration
@sumitvishwakarma56
@sumitvishwakarma56 3 ай бұрын
What if we have a distributed environment , multiple instance of this service would be running, how do we prevent multiple instances then?
@777grw
@777grw 8 ай бұрын
Simple and precise
@rhtservicestech
@rhtservicestech 11 ай бұрын
Wouldn't it make more sense to remove the outer check for the null instance? I say that because you now have the same condition duplicated in your code which isn't ideal or efficient.
@alieninoy5654
@alieninoy5654 11 ай бұрын
If the outer check is removed, the application will acquire a lock every time the instance is requested, impacting performance.
@rktmimob
@rktmimob 9 ай бұрын
explained very easy way 😊
@mateociotti3564
@mateociotti3564 9 ай бұрын
Helped a lot, thanks
@jaycorrales5329
@jaycorrales5329 Жыл бұрын
@8:40 is the critical section of this video thread.
@sefatergbashi
@sefatergbashi Жыл бұрын
Thank you!
@FranciscoAlvino
@FranciscoAlvino Жыл бұрын
Nice! Great job 👏🏻👏🏻👏🏻
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Thanks! 😊
@user-dt1cv6hs2g
@user-dt1cv6hs2g 10 ай бұрын
good one
@iamnoob7593
@iamnoob7593 Жыл бұрын
Superb
@jhonnidarshan3094
@jhonnidarshan3094 Жыл бұрын
Nice tutorial
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Thank you! Cheers!
@Matthew-sy4lj
@Matthew-sy4lj Жыл бұрын
Hi there very interesting tutorial. Unfortunately though I'm receiving two errors: 1. Program does not contain a static 'Main' method suitable for an entry point (CS5001) 2. When I try to pass values from my instance threads it says that UploadService is inaccessible due to the protect level of my class being sealed/private. I'm new to programming so I'm a bit lost at the moment as I had to create a new project/program to link it with the UploadService class. What should I do?
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Hi, awesome that you try it out! Make sure that your program cotains a "static void Main" and that you create a "public class UploadService". Also set your program class itself to "public". Greets :)
@jithumuraleedharan5231
@jithumuraleedharan5231 Жыл бұрын
Understand your C# queries! IEnumerable & IQueryable in explained
11:28
tutorialsEU - C#
Рет қаралды 34 М.
The Singleton Design Pattern - Part of the Gang of Four
28:41
IAmTimCorey
Рет қаралды 75 М.
Pool Bed Prank By My Grandpa 😂 #funny
00:47
SKITS
Рет қаралды 19 МЛН
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 21 МЛН
黑天使遇到什么了?#short #angel #clown
00:34
Super Beauty team
Рет қаралды 44 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 4,8 МЛН
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 250 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,6 МЛН
SINGLETONS in C++
19:16
The Cherno
Рет қаралды 199 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,2 МЛН
C# DELEGATES in 8 minutes! Learn .NET FAST!
8:01
tutorialsEU - C#
Рет қаралды 47 М.
how Google writes gorgeous C++
7:40
Low Level Learning
Рет қаралды 854 М.
Factory Pattern in C#: Creating Objects with Ease
12:54
campbelltech
Рет қаралды 14 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 798 М.
What is Singleton Pattern in Java - How to achieve this?
15:21
Naveen AutomationLabs
Рет қаралды 10 М.
Master C# Interfaces in 12 Minutes - Beginner Tutorial
11:37
tutorialsEU - C#
Рет қаралды 19 М.
Pool Bed Prank By My Grandpa 😂 #funny
00:47
SKITS
Рет қаралды 19 МЛН