Cs30 New

63 %
38 %
Information about Cs30 New

Published on August 7, 2007

Author: Chakravarthy

Source: slideshare.net

Description

This is the presentation to explain what's new in C# 3.0 programming language

C# 3.0 What’s new by Chakravarthy http://msmvps.com/blogs/chakravarthy [email_address] Project Lead

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types Lambda Expressions Generic Delegates Expression Trees Are we missing any thing here ?????

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types

Lambda Expressions

Generic Delegates

Expression Trees

Pre-Requisites Some Programming Exp C C ++ .NET Basics Apart of all .. Imagination is more important than knowledge .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..

Some Programming Exp

C

C ++

.NET Basics

Apart of all ..

Ur acquaintance with C# Using it more than 2 Yrs Started Recently Am new to C# What C# is ..?

Using it more than 2 Yrs

Started Recently

Am new to C#

What C# is ..?

Orcas What is ? Specialisation doesn’t mean doing extraordinary things But doing ordinary things, extraordinarily well..

Visual Studio Code Name – Orcas Web Multi version apps CSS Design tools Intellisense for ECMA Script AJAX Library Applications Templates WPF WCF WF Data Integration EDM – Entity Data Manager (ADO.NET vNext) Multi-tier Dataset Reporting Project templates

Web

Multi version apps

CSS Design tools

Intellisense for ECMA Script

AJAX Library

Applications Templates

WPF

WCF

WF

Data Integration

EDM – Entity Data Manager (ADO.NET vNext)

Multi-tier Dataset

Reporting Project templates

demo Visual Studio Code name Orcas Ctrl+Tab MultiVersion ECMA Intellisupport DataIntegration(EDM) AJAX Support CSS

Ctrl+Tab

MultiVersion

ECMA Intellisupport

DataIntegration(EDM)

AJAX Support

CSS

C# 3.0 Features If we fail to plan, we are planning to fail

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

Implicitly typed local variables Declared as ‘var’ – compiler will determine type while initialization Can only be used when declared and initialized in same statement Can’t be null Can’t be class members Used to store anonymous types as in LINQ based programming Don’t confuse with “var” at JavaScript or VB, which actually allows you to assign any type to a variable in your code Multiple declarations should evaluate at Compile time var bVal = true; var strVal = “MATUG”; Var intNum = 9; var obj = new { UGName = “Automated Test”, url = “http://matug.net”, alturl =“http://groups.msn.com/matug/”}

Declared as ‘var’ – compiler will determine type while initialization

Can only be used when declared and initialized in same statement

Can’t be null

Can’t be class members

Used to store anonymous types as in LINQ based programming

Don’t confuse with “var” at JavaScript or VB, which actually allows you to assign any type to a variable in your code

Multiple declarations should evaluate at Compile time

var bVal = true;

var strVal = “MATUG”;

Var intNum = 9;

var obj = new { UGName = “Automated Test”, url = “http://matug.net”, alturl =“http://groups.msn.com/matug/”}

Implicitly typed arrays Declared as ‘var’ – compiler will determine type while initialization Collection type of elements is determined by compiler var fstArry = new[] {3,6,11,78,93};  Int32 var secArry = new[] {3,6,11.48,78,93};  Double var thrArry = new[] {“Microsoft”, “MAQ”};  String var secArry = new[] {3,6,11.48,”78”,93};  Won’t compile due to irregularity in the elements

Declared as ‘var’ – compiler will determine type while initialization

Collection type of elements is determined by compiler

var fstArry = new[] {3,6,11,78,93};  Int32

var secArry = new[] {3,6,11.48,78,93};  Double

var thrArry = new[] {“Microsoft”, “MAQ”};  String

var secArry = new[] {3,6,11.48,”78”,93};  Won’t compile due to irregularity in the elements

demo Implicit Variables Variables Multiple Declaration Typed Arrays Arrays Mismatch

Variables

Multiple Declaration

Typed Arrays

Arrays Mismatch

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

Auto implemented properties Compiler will create the private variables Single line public property accessor Simple object persistence mechanism Old Style private string strVar; public string EmployeeName { get{return strVar;} set{strVar = value;} } C# 3.0 public string EmployeeName { get; set; } Would you like to know what happens behind the screen ?

Compiler will create the private variables

Single line public property accessor

Simple object persistence mechanism

Auto implemented properties Assembler will give you the code similar to the below namespace SampleLib { public class YesClass { // Fields [ CompilerGenerated ] private string <>k__AutomaticallyGeneratedPropertyField0 ; // Methods public YesClass (); public void DoNothing (); // Properties public string Reply { [ CompilerGenerated ] get; [ CompilerGenerated ] set; } } } How do you know this ? … Use any Reflector ..

demo Property Property Reflector

Property

Reflector

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

Object & Collection Initializers Declaration and initialization at one step Ease of construction and initialization process Sequence of members are separated by ‘,’ Should be an accessible field assigned with = operator

Declaration and initialization at one step

Ease of construction and initialization process

Sequence of members are separated by ‘,’

Should be an accessible field assigned with = operator

demo Object & Collections Object from a class Collections from a List <>

Object from a class

Collections from a List <>

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

Extension Methods Static Methods Invoked with instance method syntax Declared by “this” keyword as modifier Declared in “static” classes only Extension members of other kinds, such as properties, events, and operators, are being considered but are currently not supported.

Static Methods

Invoked with instance method syntax

Declared by “this” keyword as modifier

Declared in “static” classes only

Extension members of other kinds, such as properties, events, and operators, are being considered but are currently not supported.

demo Extension Methods Reverse the given string

Reverse the given string

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

Anonymous Types No class code declaration Direct initialization Type is omitted at syntax Not only the variables but objects can also be anonymous Old Style public class Book { … } Book bkObj = new Book(); C# 3.0 Style var bkObj = new { Title = “Harry Potter 7”, PubYr = 2007}

No class code declaration

Direct initialization

Type is omitted at syntax

Not only the variables but objects can also be anonymous

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods Did I miss something???

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

λ Lambda Expressions Extension of anonymous methods Advancement of Delegates Is an inline expression / statement block with a concise syntax that can be used wherever a delegate or anonymous method is expected which can be used to pass arguments to method call or assign value to delegate Expression use “=>” operator Left side denotes result Right side contains statement block or expression

Extension of anonymous methods

Advancement of Delegates

Is an inline expression / statement block

with a concise syntax that can be used wherever a delegate or anonymous method is expected

which can be used to pass arguments to method call or assign value to delegate

Expression use “=>” operator

Left side denotes result

Right side contains statement block or expression

Lambda Expressions // Data source. int[] Scores = { 90, 71, 82, 93, 75, 82 }; Write me some code that returns me the count for the numbers that are greater than 80 ? // This query executes immediately because it returns a singleton int value, not an iterable sequence. int scoreQuery = Scores.Where(n => n > 80).Count();

Lambda Expressions // Data source. string[] Projects = { “eZCap”, “iMedsoft”, “Patient Portal”, “LiveWellHRA”, “ETL”, “iMedLiveWell”}; Write me some code that returns me the projects that has “Med” in project name ? IEnumerable<string> projsQry = from proj in projs where proj.Contains(&quot;Med&quot;) select proj; foreach (string projName in projsQry) { Console.WriteLine(projName); }

λ Lambda Expressions – conti .. Improved type inference Conversion for both delegate types as well as expression trees Expression trees ?? Lambda expressions with an expression body can be converted to expression tree General rules Must contain same number of parameters as the delegate type Each parameter and return value must be implicitly convertible to its corresponding delegate parameter or delegate return type

Improved type inference

Conversion for both delegate types as well as expression trees

Expression trees ??

Lambda expressions with an expression body can be converted to expression tree

General rules

Must contain same number of parameters as the delegate type

Each parameter and return value must be implicitly convertible to its corresponding delegate parameter or delegate return type

demo Lambda Expressions Delegates Anonymous Methods Lambda Expressions

Delegates

Anonymous Methods

Lambda Expressions

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Methods Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Methods

Partial Methods

Generic Delegates (Func) Allows to construct a method with out declaring delegate 5 predefined generic delegates Last parameter is always return type You can extend them with LINQ Func<>

Allows to construct a method with out declaring delegate

5 predefined generic delegates

Last parameter is always return type

You can extend them with LINQ

Func<>

demo Generic Delegates Func<string, string>

Func<string, string>

Agenda What’s new in Orcas C# 3.0 Implicit Variables Auto implemented properties Object & Collection Initializers Extension Methods Anonymous Types / Tuples Lambda Expressions Generic Delegates (Func) Expression Trees Partial Methods

What’s new in Orcas

C# 3.0

Implicit Variables

Auto implemented properties

Object & Collection Initializers

Extension Methods

Anonymous Types / Tuples

Lambda Expressions

Generic Delegates (Func)

Expression Trees

Partial Methods

Expression Trees Don’t get confuse System.LINQ.Expression with Windows.Forms Allow lamda expressions as data instead of code Expression<>

Don’t get confuse System.LINQ.Expression with Windows.Forms

Allow lamda expressions as data instead of code

Expression<>

demo Expression Trees Expression<Func<string, string>> Expression.Compile

Expression<Func<string, string>>

Expression.Compile

Q&A

For further win/win var WhoIsThereNextMonth = new { Default = “Chakravarthy”, Perhaps = “Sarma & Siva”, AreYou =“NotSure”, Topics =“What do you Want ??”, AnyThing =“Don’t hesitate, ASK ME” }

var WhoIsThereNextMonth = new {

Default = “Chakravarthy”,

Perhaps = “Sarma & Siva”,

AreYou =“NotSure”,

Topics =“What do you Want ??”,

AnyThing =“Don’t hesitate, ASK ME”

}

Where to go for any technical Post your message at http:// groups.msn.com/CSharpGroup Drop me a line at chakravarthy.dsk@inteq Visit our sessions on “KS” Knowledge Share with out fail

Post your message at http:// groups.msn.com/CSharpGroup

Drop me a line at chakravarthy.dsk@inteq

Visit our sessions on “KS” Knowledge Share with out fail

Next ???

Add a comment

Related presentations

Related pages

Elva - Mobile Customer Service and In-app Help Desk

CS30 is an in-app customer support platform that enables mobile apps to improve customer experience, drive higher ratings and increase retention.
Read more

ryobi cs 30 | eBay

Find great deals on eBay for ryobi cs 30 and ryobi carburetor. ... Ryobi/Homelite A98231A Spool Housing for ZRRY26500 CS30 String Trimmer # New. $13.24 ...
Read more

CS30/CS31 Chainsaw Maintenance, Cross Cutting and Basic ...

CS30/CS31 Chainsaw Maintenance, Cross Cutting and Basic Felling Training including Refresher Courses
Read more

Ryobi String Trimmer Model CS30 Parts: Fast Shipping

Ryobi String Trimmer Model CS30 Parts - Shop online or call 800-269-2609. ... This part includes a new tank, fuel line, fuel filter, and cap.
Read more

ryobi cs30 | eBay

Find great deals on eBay for ryobi cs30 and ryobi carburetor. Shop with confidence.
Read more

yamaha cs-30 demo - YouTube

yamaha cs-30 demo ... New; 9:09 Yamaha CS30 Noodling normal sounds - Duration: 2:54. Magnus Gladén 2,051 views. 2:54
Read more

New to CS30 - SailNet Community

Hi I'm new to this Forum. Sold my 37' Looking at a couple of CS30's shoal draft. What should I look for? We have cruised extensivly to the Caraibbean,
Read more

RYOBI CS30, SS30, BC30 OPERATOR'S MANUAL Pdf Download.

CS30, SS30, BC30 Trimmer pdf manual download. Sign In. Upload. Page of 28 Go. ... Your new trimmer has been engineered and manufactured to Ryobi's high ...
Read more

CS30 Coin Counter & Sorter | Products | ZZap Online

With one of the fastest counting speeds of any coin sorter in this price bracket, the CS30 is setting new standards. Its hopper and tray capacities offer ...
Read more