Skip to main content

Chaining Methods - C# Intermediate Tutorials

CHAINING METHODS IN C#

INTERMEDIATE TUTORIAL

by Chamuth Chamandana



What are Chaining Methods?

=======================

Chaining Methods are used in C# in many ways. In extension methods and extension libraries such as LINQ, we use Chaining methods to pass the modified variable to the next method.



Example (built-in methods):

var result = "Hello World".Replace("World", "Chamuth").ToLower().Substring(5);



What we're going to talk about in this video

==================================

We're making a class known as StringDeveloper which creates strings from adding other strings which implements Chaining functionality. Which means every method returns itself, the context using return this; statement at the end of the changing of the content of the object which lets us call other functions in the object/class after.



Chaining Methods are also available in every other programming language including C, Java, JavaScript and etc.



Let me know what you want to know more about, in the comments section. If you enjoy please Subscribe to my channel and encourage us by liking our videos!!!



Comments

Popular posts from this blog

Animating Objects in WPF using Code Behind (C#)

A Feature that is built in to the WPF Platform is the ability to animate content without using Timers. That is inside the System.Windows.Media.Animation namespace. In this video, I'm going to help you with creating animations using the code behind (C#)

Command Prompt යනු කුමක්ද?

Microsoft සමාගම විසින් I/O (Input or Output) කර්‍යයන් පහසු කිරීමට Command Promt. නම් Console Based Program එක Windows හි Poor User Interfaced Controller Program එක ලෙස Windows සමගම Release කරන ලද Program එකකි. Command Prompt වැනි වැඩසටහනකට කර හැක්කේ මොනවාද? Command Prompt. වැඩසටහනෙන් තම පරිගණකයේ ගොනු පද්දතිය (File System) එක පාලනය කල හැකි බව ඔනෑම පුද්ගලයෙක් දන්නවා. එහෙත් මෙයි ඊට වඩා වැඩක් කරගත හැකි බව දැනගත යුතුය, එමෙන්ම එවැනි වැදගත් කරුණු මෙම ලිපියේ දී ඔබට දැනගත හැකිවනු ඇත. GUI එකක් තිබෙද්දී මෙය පාවිච්චි කරන්නේ ඇයි? GUI (Graphical User Interface) එනම් අපට ඇසට ප්‍රියජනක ලෙස දැකගත හැකිවන පරිදි Colors, Images වැනි Windows Controls යොදාගෙන සාදා ඇති අතුරු මුහුනතක් (Windows Explorer) Windows සමග ඔබට ලැබෙනු ඇත. එහෙත් සාම්ප්‍රදායිකව Windows සමග ඔබට ලැබෙන මේ වැඩසටහන පාවිච්චි කිරීමටද වැදගත් හේතු කිහිපයක් තිබේ. 1. Windows Explorer නම් වැඩසටහනට නොපෙනෙන හෝ Restricted කලාපයන්ට ඇතුලත් වීමට Command Prompt වැඩසටහනට හැකියාවක් ඇත. 2. Windows Explorer වැනි වැඩසටහනක් මේ වන විට දියුණුවෙන් දියු...

C:\ Drive එක Compress නොකල යුත්තේ ඇයි?

අප කවුරුත් දන්නවා Windows install කරපසුව C:\ නමින් ඇති Drive එක Windows Installation Drive එක වන බව. කොටින්ම කියනවානම් C:\ යනු පරිගණකයේ ඇති වැදගත්ම Hard Disk Partition එක ලෙස සැලකිය හැකිය. මන්ද Windows Run කිරීමට අත්‍යවශ්‍ය Files සියල්ලම ඇත්තේ C:\ නම් Disk එකේය. යම්කිසි Drive එකක් Compress කිරීමෙන් සිදුවන්නේ එහි ඇති Files Access වීමට පෙර යම්කිසි Algorithm එකකට Compress වීමයි (මෙය Disk Space එක වැඩි කරදෙයි). එම Files වලට හරි ආකාරව Access වීමේදී ඒවා නැවත Decompress වී Open වෙයි. මෙයට යම් කාලයක් ගතවෙයි. එහෙත් C:\ හැරුණු විට අනෙකුත් Drives වලට එයින් කිසිදු හානියක් සිදු වන්නේ නැත. C:\Windows\ යනු පරිගණකයේ Windows Installation path එක කියා කවුරුත් දන්නවා. එහි ඇති BootMGR වැනි Boot වීමට වැදගත් Files වලට Boot වීමේදී Decompress කිරීමට අවසරයක් නැත. එම නිසා ඔබගේ පරිගණකය ඔබට් Boot කිරීමට නොහැකි වනු ඇත.