- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are Local functions in C# 7.0?
Local functions are private methods of a type that are nested in another member. They can only be called from their containing member.
Local functions can be declared in and called from −
Methods, especially iterator methods and async methods
Constructors
Property accessors
Event accessors
Anonymous methods
Lambda expressions
Finalizers
Other local functions
Example 1
class Program{ public static void Main(){ void addTwoNumbers(int a, int b){ System.Console.WriteLine(a + b); } addTwoNumbers(1, 2); Console.ReadLine(); } }
Output
3
Example 2
class Program{ public static void Main(){ void addTwoNumbers(int a, int b, out int c){ c = a + b; } addTwoNumbers(1, 2, out int c); System.Console.WriteLine(c); Console.ReadLine(); } }
Output
3
- Related Articles
- What are Deconstructors in C# 7.0?
- What are the improvements in Out Parameter in C# 7.0?
- What are binary literals and digit separators in C# 7.0?
- What are Ref locals and Ref returns in C# 7.0?
- What is Pattern Matching in C# 7.0?
- What are local variables in C++?
- What are virtual functions in C#?
- What are local variables and global variables in C++?
- What are the local static variables in C language?
- What are static member functions in C#?
- What are the C library functions?
- What are the predefined functions in C language?
- What are string searching functions in C language?
- What are the local and global scope rules in C language?
- What are Local Scope Variables in Postman?

Advertisements