C# Expression Bodied Getters and Setters - javatpoint

文章推薦指數: 80 %
投票人數:10人

C# Expression bodied getters and setters ... C# expression body is a single line expression statement. It is used to provide single life definition to the method, ... ⇧SCROLLTOTOP Home .Net C# ADO.NET ASP.NET SQLServer F# AngularJS Node.js Express.js SQL HTML JavaScript Ajax Quiz Projects InterviewQ Comment Forum Training .NetFramework .NETFramework CLR FCL C#Tutorial C#Tutorial JavavsC# C#History C#Features C#Example C#Variables C#DataTypes C#Operators C#Keywords C#ControlStatement C#if-else C#switch C#ForLoop C#WhileLoop C#Do-WhileLoop C#Break C#Continue C#Goto C#Comments C#Function C#Function C#CallByValue C#CallByReference C#OutParameter C#Arrays C#Arrays C#ArraytoFunction C#MultidimensionalArray C#JaggedArrays C#Params C#Arrayclass C#CommandLineArgs C#ObjectClass C#ObjectandClass C#Constructor C#Destructor C#this C#static C#staticclass C#staticconstructor C#Structs C#Enum C#Properties C#Properties C#Inheritance C#Inheritance C#Aggregation C#Polymorphism C#MemberOverloading C#MethodOverriding C#Base C#Polymorphism C#Sealed C#Abstraction C#Abstract C#Interface C#Namespace C#Namespaces C#AccessModifiers C#Encapsulation C#Strings C#Strings C#ExceptionHandling C#ExceptionHandling C#try/catch C#finally C#CustomException C#checkedunchecked C#SystemException C#FileIO C#FileStream C#StreamWriter C#StreamReader C#TextWriter C#TextReader C#BinaryWriter C#BinaryReader C#StringWriter C#StringReader C#FileInfo C#DirectoryInfo C#Serialization C#Deserialization C#System.IO C#Collections C#Collections C#List C#HashSet C#SortedSet C#Stack C#Queue C#LinkedList C#Dictionary C#SortedDictionary C#SortedList C#Generics C#Generics C#Delegates C#Delegates C#Reflection C#Reflection AnonymousFunction AnonymousFunction C#Multithreading C#Multithreading C#ThreadLifeCycle C#Threadclass C#MainThread C#ThreadExample C#ThreadSleep C#ThreadAbort C#ThreadJoin C#ThreadName C#ThreadPriority C#Synchronization C#Synchronization C#WebService WebServicesinC# C#Misc EventsinC# RegularExpressioninC# DateTimeinC# TypeCastinginC# ListBoxControlinC# C#ReadLine()Method DesignPatternsC# C#OperatorOverloading C#NewFeatures C#NewFeatures(40+) C#Programs C#Programs FibonacciSeries PrimeNumber PalindromeNumber Factorial ArmstrongNumber Sumofdigits ReverseNumber SwapNumber DecimaltoBinary NumberinCharacters AlphabetTriangle NumberTriangle FibonacciTriangle C#InterviewQuestions C#InterviewQuestions ADO.NETTutorial ADO.NETTutorial(10+) ASP.NETTutorial ASP.NETTutorial(50+) next→ ←prev C#Expressionbodiedgettersandsetters C#expressionbodyisasinglelineexpressionstatement.Itisusedtoprovidesinglelifedefinitiontothemethod,constructororproperty.Wecanuseittoprovidedefinitionforthegetterandsetter. Inthefollowingexample,weareprovidingexpressionbodyforthegetterandsetters. C#ExpressionbodiedgettersandsettersExample usingSystem; namespaceCSharpFeatures { classStudent { privatestringSName; publicStudent(stringname)=>SName=name; publicstringName{ get=>SName;//Expressionbodyforgetter set=>SName=value;//Expressionbodyforsetter } } classExpressionExample { publicstaticvoidMain() { Studentstudent=newStudent("Peter"); Console.WriteLine(student.Name); } } } Output: Peter NextTopicC#AsyncMain ←prev next→ ForVideosJoinOurYoutubeChannel:JoinNow Feedback SendyourFeedbackto[email protected] HelpOthers,PleaseShare LearnLatestTutorials Splunk SPSS Swagger Transact-SQL Tumblr ReactJS Regex ReinforcementLearning RProgramming RxJS ReactNative PythonDesignPatterns PythonPillow PythonTurtle Keras Preparation Aptitude Reasoning VerbalAbility InterviewQuestions CompanyQuestions TrendingTechnologies ArtificialIntelligence AWS Selenium CloudComputing Hadoop ReactJS DataScience Angular7 Blockchain Git MachineLearning DevOps B.Tech/MCA DBMS DataStructures DAA OperatingSystem ComputerNetwork CompilerDesign ComputerOrganization DiscreteMathematics EthicalHacking ComputerGraphics SoftwareEngineering WebTechnology CyberSecurity Automata CProgramming C++ Java .Net Python Programs ControlSystem DataMining DataWarehouse JavatpointServicesJavaTpointofferstoomanyhighqualityservices.Mailuson[email protected],togetmoreinformationaboutgivenservices.WebsiteDesigningWebsiteDevelopmentJavaDevelopmentPHPDevelopmentWordPressGraphicDesigningLogoDigitalMarketingOnPageandOffPageSEOPPCContentDevelopmentCorporateTrainingClassroomandOnlineTrainingDataEntryTrainingForCollegeCampusJavaTpointofferscollegecampustrainingonCoreJava,AdvanceJava,.Net,Android,Hadoop,PHP,WebTechnologyandPython.Pleasemailyourrequirementat[email protected]Duration:1weekto2weekLike/Subscribeusforlatestupdatesornewsletter



請為這篇文章評分?