By:
Morteza Zakeri
PhD Student
Iran University of Science and Technology
Winter 2020
Part 3: Getting Started in C#
2
Agenda
• ANTLR in Visual Studio 2019 and C#
• Back to the Grammar
• Implement Your First Visitor
• Listeners vs Visitors
11 February 2020 Introduction to ANTLR – Morteza Zakeri
3
ANTLR in Visual Studio 2019 and C#
• Install AntlrVSIX
11 February 2020 Introduction to ANTLR – Morteza Zakeri
4
ANTLR in Visual Studio 2019 and C#
• Create a new project
• Use .NET 4.6.x 
11 February 2020 Introduction to ANTLR – Morteza Zakeri
5
ANTLR in Visual Studio 2019 and C#
• Download and Install JDK
• Download ANTLR jar file
• antlr.org/download/antlr-4.8-
complete.jar
• Set Environment variables
• JAVA_HOME
• Antrl4ToolPath
11 February 2020 Introduction to ANTLR – Morteza Zakeri
6
Antlr4BuildTasks
• The purpose of the package is to integrate the Antlr tool into
the building of NET programs that reference Antlr using the
Java-based Antlr tool.
• The advantage of this package is that it decouples the Java-
based Antlr tool from the package itself.
• Make sure you do not have a version skew between the Java
Antlr tool and the runtime versions.
11 February 2020 Introduction to ANTLR – Morteza Zakeri
7
Back to the Grammar
• Expr.g4
11 February 2020 Introduction to ANTLR – Morteza Zakeri
8
Build and Run Your Project
11 February 2020 Introduction to ANTLR – Morteza Zakeri
9
Implement Your First Visitor
11 February 2020 Introduction to ANTLR – Morteza Zakeri
var visitor = new MyExprVisitor<string>();
var result = visitor.Visit(tree);
10
Listener vs Visitor
• Listener methods are called automatically by the ANTLR
provided walker object, whereas visitor methods must walk
their children with explicit visit calls. Forgetting to invoke
visit() on a node’s children means those subtrees don’t get
visited.
11 February 2020 Introduction to ANTLR – Morteza Zakeri
11
Listener vs Visitor
• Listener methods can’t return a value, whereas visitor
methods can return any custom type. With listener, you will
have to use mutable variables to store values, whereas with
visitor there is no such need.
11 February 2020 Introduction to ANTLR – Morteza Zakeri
12
Listener vs Visitor
• Listener uses an explicit stack allocated on the heap,
whereas visitor uses call stack to manage tree traversals. This
might lead to StackOverflow exceptions while using visitor
on deeply nested ASTs.
• Read more:
• https://saumitra.me/blog/antlr4-visitor-vs-listener-pattern/
• https://jakubdziworski.github.io/java/2016/04/01/antlr_visitor_vs
_listener.html
11 February 2020 Introduction to ANTLR – Morteza Zakeri
13
Assignments and Projects
11 February 2020 Introduction to ANTLR – Morteza Zakeri
14
Assignments and Projects
• Assignment 0: C++ (Python) lexical and syntax analyzing
• Assignment 1: Instrumenting the C++ (Python) source codes
based on independent execution paths.
• Assignment 2: Refactoring C++ (Python) source codes based
on clean code principles (Robert C. Martin book).
• Assignment 3: Extracting class diagram (annotated directed
graph) from C++ (Python) source code.
• Assignment 5 (Optional): Identifying the design patterns in
the code.
11 February 2020 Introduction to ANTLR – Morteza Zakeri
15
Assignments and Projects
• Final Project: Put all together 
• A comprehensive tool for program analysis!
11 February 2020 Introduction to ANTLR – Morteza Zakeri
16
Assignment 0: Build Compiler Front-end
• Put your compiler knowledge in practice!
• A software engineer with compiler science.
• Download the C++ (Python) grammar from ANTLR GitHub
pages.
• https://github.com/antlr/grammars-v4
11 February 2020 Introduction to ANTLR – Morteza Zakeri
17
Assignment 1: Instrumentation
• Part 1: Simple instrumenting
• Input: C++ (Python) source code
• Output: C++ (Python) instrumented source code
11 February 2020 Introduction to ANTLR – Morteza Zakeri
18
Assignment 1: Instrumentation
• Example 1:
• Input and Output
11 February 2020 Introduction to ANTLR – Morteza Zakeri
19
Assignment 1: Instrumentation
• Another example (GCD program):
11 February 2020 Introduction to ANTLR – Morteza Zakeri
20
Assignment 1: Instrumentation
• Problem solving idea
• Implement listener for two Non-terminals
• Rewriting the Input Stream
11 February 2020 Introduction to ANTLR – Morteza Zakeri
public override void EnterStatement([NotNull]CPP14Parser.StatementContext context)
{
// put your code here
}
public override void EnterFunctionbody([NotNull] CPP14Parser.FunctionbodyContext
context){
// put your code here
}
21
Assignment 1: Instrumentation
• Part 2: Deal with some challenges
• Block with Single Statements
11 February 2020 Introduction to ANTLR – Morteza Zakeri
22
Assignment 1: Instrumentation
• Problem solving idea
• Implement listener for two Non-terminals:
11 February 2020 Introduction to ANTLR – Morteza Zakeri
23
Assignment 1: Instrumentation
• Part 3: Deal with some challenges
• Loops make some problems, e.g.:
gcd.exe < 6 4
<p(1)p(2)p(3)p(2)p(3)p(2)p(2)end>
< p(1)p(2)p(3)end >
• Or
 gcd.exe < 24 16
<p(1)p(2)p(3)p(2)p(3)p(2)p(2)p(3)p(2)p(2)p(2)p(2)p(3)p(2)
p(2)p(2)p(2)p(2)p(2)p(2)p(2)end>
11 February 2020 Introduction to ANTLR – Morteza Zakeri
24
Assignment 1: Instrumentation
• Tips for a solution (function level):
• Reduce each sequence to independent
execution path
• Independent execution paths can be
computed using CFG
• Use Antlr to extract CGF and Independent
execution paths:
i. <p(1)p(2)p(3)end>
ii. <p(1)p(2)end>
iii. <p(1)end>
11 February 2020 Introduction to ANTLR – Morteza Zakeri
25
Assignment 1: Instrumentation
• Tips for a solution (program level):
• We cared about functions, i.e., unit testing 
• Testing at function level
• What about program? 
• Testing at program level (integration testing)
• In the level of program we need call flow graph
• Use Antlr to extract call flow graph
11 February 2020 Introduction to ANTLR – Morteza Zakeri
26
Assignment 2: Clean Code
• Part 1: Find the clean code violence in names, functions,
comments, and formatting, based on the Clean Code book
by Robert C. Martin.
• Read chapters 1 – 5
• Using ANTLR
• Report the result to the programmer
11 February 2020 Introduction to ANTLR – Morteza Zakeri
Robert C. Martin
27
Assignment 2: Clean Code
• Part 2: Refactor the founded clean code violence
automatically.
• Again using ANTLR
• Using NLTK for naming
• https://www.nltk.org/
11 February 2020 Introduction to ANTLR – Morteza Zakeri
28
Assignment 3: Class Diagram Extraction
• We will talk about it in the next sessions.
11 February 2020 Introduction to ANTLR – Morteza Zakeri
29
Project
• Final Project: Put all assignment together
• Policies
• Student with odd digit in last of their ID number (e.g. 9513231117):
• Prepare your tools for Python3
• Other students (e.g. 9513231118):
• Prepare your tools for CPP14
• Deadlines:
• Assignment 1 and 2 deadlines: 20 Farvardin 1399.
• Assignment 3 deadline will be determined later!
11 February 2020 Introduction to ANTLR – Morteza Zakeri
30
Commercialize Your Tool
11 February 2020 Introduction to ANTLR – Morteza Zakeri
31
References
1. AntlrVSIX
• https://github.com/kaby76/AntlrVSIX/blob/master/doc/readme.md
2. Getting Started With ANTLR in C#
1. https://dzone.com/articles/getting-started-with-antlr-in-c
3. The Definitive ANTLR 4 Reference
• Terence Parr, The Pragmatic Programmers, LLC; 2012.
4. ANTLR 4 Official Website:
• http://www.antlr.org/
11 February 2020 Introduction to ANTLR – Morteza Zakeri
o Do you have any question?
• m - z a ke r i @ l i v e . c o m
11 February 2020 Introduction to ANTLR – Morteza Zakeri
33
Appendix
• Extension Methods in C#
• $ in C# Strings
34
Extension Methods in C#
• Extension methods enable you to "add" methods to existing
types
• without creating a new derived type, recompiling, or otherwise
modifying the original type.
• special kind of static method, but they are called as if they were
instance methods on the extended type.
• The most common extension methods are the LINQ standard
query operators that add query functionality to the existing
System.Collections.IEnumerable and
System.Collections.Generic.IEnumerable<T> types.
11 February 2020 Introduction to ANTLR – Morteza Zakeri
35
Extension Methods in C#
11 February 2020 Introduction to ANTLR – Morteza Zakeri
36
$ in C# Strings
• $ is short-hand for String.Format() and is used with string
interpolations, which is a new feature of C# 6.
11 February 2020 Introduction to ANTLR – Morteza Zakeri

More Related Content

PPTX
Antlr part1 introduction
PPTX
Antlr part2 getting_started_in_java
PPTX
An Introduction to ANTLR
PDF
An Introduction to Python Programming
PPTX
Which programming language to learn R or Python - MeasureCamp XII
PPTX
2. introduction to compiler
PDF
Python indroduction
 
PPTX
2. introduction
Antlr part1 introduction
Antlr part2 getting_started_in_java
An Introduction to ANTLR
An Introduction to Python Programming
Which programming language to learn R or Python - MeasureCamp XII
2. introduction to compiler
Python indroduction
 
2. introduction

Similar to Antlr part3 getting_started_in_c_sharp (20)

PDF
PDF
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
ODP
PPTX
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
PDF
Template Haskell
ODP
Using ANTLR on real example - convert "string combined" queries into paramete...
PPTX
ANTLR - Writing Parsers the Easy Way
PDF
Generative programming (mostly parser generation)
ODP
ANTLR4 and its testing
PPT
introduction_to_antlr 3.ppt
PDF
An introduction on language processing
PDF
Automated antlr tree walker
PDF
Thoughts On Learning A New Programming Language
ODP
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
PDF
T3chFest 2016 - The polyglot programmer
PDF
The Next Great Functional Programming Language
PPTX
Antlr4 get the right tool for the job
PDF
Diving into Functional Programming
KEY
Antlr Conference Drools & Hibernate
PDF
Custom Query Languages: Why? How?
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Template Haskell
Using ANTLR on real example - convert "string combined" queries into paramete...
ANTLR - Writing Parsers the Easy Way
Generative programming (mostly parser generation)
ANTLR4 and its testing
introduction_to_antlr 3.ppt
An introduction on language processing
Automated antlr tree walker
Thoughts On Learning A New Programming Language
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
T3chFest 2016 - The polyglot programmer
The Next Great Functional Programming Language
Antlr4 get the right tool for the job
Diving into Functional Programming
Antlr Conference Drools & Hibernate
Custom Query Languages: Why? How?
Ad

More from Morteza Zakeri (20)

PPTX
9-roslyn-guidelines
PPTX
7-clean-code
PPTX
8-bad-smells
PPTX
PPTX
3-use-casemodelling
PPTX
5-modular-design
PPTX
4-architectural-views
PPTX
2-requirements-modelling
PPTX
1-requirements-elicitation
PDF
Analysis of Social Phenomena Using Machine Learning Techniques: A Mixed Resea...
PDF
Internet of Things: Middle-ware Platforms, Security, and Intrusion Detection
PDF
Community Detection with Genetic Algorithm
PPTX
SpotifyX Architectural Review
PDF
An overview of anomaly detection techniques
PPTX
SQLite and object-relational mapping in Java
PPTX
Apache Mesos: Architecture, Design and Code Review
PPTX
یادگیری توالی به توالی با شبکه های عصبی
PDF
Sequence to sequence learning with neural networks
PDF
Bridge Management System Using NoSQL Solutions
PDF
Extracting architectural model of software from source code
9-roslyn-guidelines
7-clean-code
8-bad-smells
3-use-casemodelling
5-modular-design
4-architectural-views
2-requirements-modelling
1-requirements-elicitation
Analysis of Social Phenomena Using Machine Learning Techniques: A Mixed Resea...
Internet of Things: Middle-ware Platforms, Security, and Intrusion Detection
Community Detection with Genetic Algorithm
SpotifyX Architectural Review
An overview of anomaly detection techniques
SQLite and object-relational mapping in Java
Apache Mesos: Architecture, Design and Code Review
یادگیری توالی به توالی با شبکه های عصبی
Sequence to sequence learning with neural networks
Bridge Management System Using NoSQL Solutions
Extracting architectural model of software from source code
Ad

Recently uploaded (20)

PPTX
climate change of delhi impacts on climate and there effects
PPTX
pharmaceutics-1unit-1-221214121936-550b56aa.pptx
PPT
hsl powerpoint resource goyloveh feb 07.ppt
PPTX
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
PDF
LATAM’s Top EdTech Innovators Transforming Learning in 2025.pdf
PDF
Physical pharmaceutics two in b pharmacy
PPTX
Approach to a child with acute kidney injury
DOCX
EDUCATIONAL ASSESSMENT ASSIGNMENT SEMESTER MAY 2025.docx
PPTX
PAIN PATHWAY & MANAGEMENT OF ACUTE AND CHRONIC PAIN SPEAKER: Dr. Rajasekhar ...
PPTX
MMW-CHAPTER-1-final.pptx major Elementary Education
PPTX
Key-Features-of-the-SHS-Program-v4-Slides (3) PPT2.pptx
PPTX
Diploma pharmaceutics notes..helps diploma students
PDF
Kalaari-SaaS-Founder-Playbook-2024-Edition-.pdf
PPTX
IT infrastructure and emerging technologies
PPSX
namma_kalvi_12th_botany_chapter_9_ppt.ppsx
PPTX
CHROMIUM & Glucose Tolerance Factor.pptx
PDF
HSE 2022-2023.pdf الصحه والسلامه هندسه نفط
PDF
Unleashing the Potential of the Cultural and creative industries
PPTX
Theoretical for class.pptxgshdhddhdhdhgd
PDF
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
climate change of delhi impacts on climate and there effects
pharmaceutics-1unit-1-221214121936-550b56aa.pptx
hsl powerpoint resource goyloveh feb 07.ppt
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
LATAM’s Top EdTech Innovators Transforming Learning in 2025.pdf
Physical pharmaceutics two in b pharmacy
Approach to a child with acute kidney injury
EDUCATIONAL ASSESSMENT ASSIGNMENT SEMESTER MAY 2025.docx
PAIN PATHWAY & MANAGEMENT OF ACUTE AND CHRONIC PAIN SPEAKER: Dr. Rajasekhar ...
MMW-CHAPTER-1-final.pptx major Elementary Education
Key-Features-of-the-SHS-Program-v4-Slides (3) PPT2.pptx
Diploma pharmaceutics notes..helps diploma students
Kalaari-SaaS-Founder-Playbook-2024-Edition-.pdf
IT infrastructure and emerging technologies
namma_kalvi_12th_botany_chapter_9_ppt.ppsx
CHROMIUM & Glucose Tolerance Factor.pptx
HSE 2022-2023.pdf الصحه والسلامه هندسه نفط
Unleashing the Potential of the Cultural and creative industries
Theoretical for class.pptxgshdhddhdhdhgd
Horaris_Grups_25-26_Definitiu_15_07_25.pdf

Antlr part3 getting_started_in_c_sharp

  • 1. By: Morteza Zakeri PhD Student Iran University of Science and Technology Winter 2020 Part 3: Getting Started in C#
  • 2. 2 Agenda • ANTLR in Visual Studio 2019 and C# • Back to the Grammar • Implement Your First Visitor • Listeners vs Visitors 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 3. 3 ANTLR in Visual Studio 2019 and C# • Install AntlrVSIX 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 4. 4 ANTLR in Visual Studio 2019 and C# • Create a new project • Use .NET 4.6.x  11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 5. 5 ANTLR in Visual Studio 2019 and C# • Download and Install JDK • Download ANTLR jar file • antlr.org/download/antlr-4.8- complete.jar • Set Environment variables • JAVA_HOME • Antrl4ToolPath 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 6. 6 Antlr4BuildTasks • The purpose of the package is to integrate the Antlr tool into the building of NET programs that reference Antlr using the Java-based Antlr tool. • The advantage of this package is that it decouples the Java- based Antlr tool from the package itself. • Make sure you do not have a version skew between the Java Antlr tool and the runtime versions. 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 7. 7 Back to the Grammar • Expr.g4 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 8. 8 Build and Run Your Project 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 9. 9 Implement Your First Visitor 11 February 2020 Introduction to ANTLR – Morteza Zakeri var visitor = new MyExprVisitor<string>(); var result = visitor.Visit(tree);
  • 10. 10 Listener vs Visitor • Listener methods are called automatically by the ANTLR provided walker object, whereas visitor methods must walk their children with explicit visit calls. Forgetting to invoke visit() on a node’s children means those subtrees don’t get visited. 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 11. 11 Listener vs Visitor • Listener methods can’t return a value, whereas visitor methods can return any custom type. With listener, you will have to use mutable variables to store values, whereas with visitor there is no such need. 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 12. 12 Listener vs Visitor • Listener uses an explicit stack allocated on the heap, whereas visitor uses call stack to manage tree traversals. This might lead to StackOverflow exceptions while using visitor on deeply nested ASTs. • Read more: • https://saumitra.me/blog/antlr4-visitor-vs-listener-pattern/ • https://jakubdziworski.github.io/java/2016/04/01/antlr_visitor_vs _listener.html 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 13. 13 Assignments and Projects 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 14. 14 Assignments and Projects • Assignment 0: C++ (Python) lexical and syntax analyzing • Assignment 1: Instrumenting the C++ (Python) source codes based on independent execution paths. • Assignment 2: Refactoring C++ (Python) source codes based on clean code principles (Robert C. Martin book). • Assignment 3: Extracting class diagram (annotated directed graph) from C++ (Python) source code. • Assignment 5 (Optional): Identifying the design patterns in the code. 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 15. 15 Assignments and Projects • Final Project: Put all together  • A comprehensive tool for program analysis! 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 16. 16 Assignment 0: Build Compiler Front-end • Put your compiler knowledge in practice! • A software engineer with compiler science. • Download the C++ (Python) grammar from ANTLR GitHub pages. • https://github.com/antlr/grammars-v4 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 17. 17 Assignment 1: Instrumentation • Part 1: Simple instrumenting • Input: C++ (Python) source code • Output: C++ (Python) instrumented source code 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 18. 18 Assignment 1: Instrumentation • Example 1: • Input and Output 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 19. 19 Assignment 1: Instrumentation • Another example (GCD program): 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 20. 20 Assignment 1: Instrumentation • Problem solving idea • Implement listener for two Non-terminals • Rewriting the Input Stream 11 February 2020 Introduction to ANTLR – Morteza Zakeri public override void EnterStatement([NotNull]CPP14Parser.StatementContext context) { // put your code here } public override void EnterFunctionbody([NotNull] CPP14Parser.FunctionbodyContext context){ // put your code here }
  • 21. 21 Assignment 1: Instrumentation • Part 2: Deal with some challenges • Block with Single Statements 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 22. 22 Assignment 1: Instrumentation • Problem solving idea • Implement listener for two Non-terminals: 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 23. 23 Assignment 1: Instrumentation • Part 3: Deal with some challenges • Loops make some problems, e.g.: gcd.exe < 6 4 <p(1)p(2)p(3)p(2)p(3)p(2)p(2)end> < p(1)p(2)p(3)end > • Or  gcd.exe < 24 16 <p(1)p(2)p(3)p(2)p(3)p(2)p(2)p(3)p(2)p(2)p(2)p(2)p(3)p(2) p(2)p(2)p(2)p(2)p(2)p(2)p(2)end> 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 24. 24 Assignment 1: Instrumentation • Tips for a solution (function level): • Reduce each sequence to independent execution path • Independent execution paths can be computed using CFG • Use Antlr to extract CGF and Independent execution paths: i. <p(1)p(2)p(3)end> ii. <p(1)p(2)end> iii. <p(1)end> 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 25. 25 Assignment 1: Instrumentation • Tips for a solution (program level): • We cared about functions, i.e., unit testing  • Testing at function level • What about program?  • Testing at program level (integration testing) • In the level of program we need call flow graph • Use Antlr to extract call flow graph 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 26. 26 Assignment 2: Clean Code • Part 1: Find the clean code violence in names, functions, comments, and formatting, based on the Clean Code book by Robert C. Martin. • Read chapters 1 – 5 • Using ANTLR • Report the result to the programmer 11 February 2020 Introduction to ANTLR – Morteza Zakeri Robert C. Martin
  • 27. 27 Assignment 2: Clean Code • Part 2: Refactor the founded clean code violence automatically. • Again using ANTLR • Using NLTK for naming • https://www.nltk.org/ 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 28. 28 Assignment 3: Class Diagram Extraction • We will talk about it in the next sessions. 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 29. 29 Project • Final Project: Put all assignment together • Policies • Student with odd digit in last of their ID number (e.g. 9513231117): • Prepare your tools for Python3 • Other students (e.g. 9513231118): • Prepare your tools for CPP14 • Deadlines: • Assignment 1 and 2 deadlines: 20 Farvardin 1399. • Assignment 3 deadline will be determined later! 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 30. 30 Commercialize Your Tool 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 31. 31 References 1. AntlrVSIX • https://github.com/kaby76/AntlrVSIX/blob/master/doc/readme.md 2. Getting Started With ANTLR in C# 1. https://dzone.com/articles/getting-started-with-antlr-in-c 3. The Definitive ANTLR 4 Reference • Terence Parr, The Pragmatic Programmers, LLC; 2012. 4. ANTLR 4 Official Website: • http://www.antlr.org/ 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 32. o Do you have any question? • m - z a ke r i @ l i v e . c o m 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 33. 33 Appendix • Extension Methods in C# • $ in C# Strings
  • 34. 34 Extension Methods in C# • Extension methods enable you to "add" methods to existing types • without creating a new derived type, recompiling, or otherwise modifying the original type. • special kind of static method, but they are called as if they were instance methods on the extended type. • The most common extension methods are the LINQ standard query operators that add query functionality to the existing System.Collections.IEnumerable and System.Collections.Generic.IEnumerable<T> types. 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 35. 35 Extension Methods in C# 11 February 2020 Introduction to ANTLR – Morteza Zakeri
  • 36. 36 $ in C# Strings • $ is short-hand for String.Format() and is used with string interpolations, which is a new feature of C# 6. 11 February 2020 Introduction to ANTLR – Morteza Zakeri