.NET 2.0 and Visual Studio 2005 - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

.NET 2.0 and Visual Studio 2005

Description:

Anonymous methods. Review of delegates. Anonymous delegate=delegate without a function name, just code. Anonymous method example: ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 13
Provided by: david1358
Category:
Tags: net | anon | studio | visual

less

Transcript and Presenter's Notes

Title: .NET 2.0 and Visual Studio 2005


1
.NET 2.0 and Visual Studio 2005
  • SigWin 2004

2
Outline
  • Language enhancements in C
  • Generics
  • Partial types
  • Anonymous methods
  • Nullable types
  • IDE features
  • Intellisense
  • Refractoring
  • Code snippets
  • Other awesome stuff!

3
Generics
  • Motivation

4
Generics
  • One method
  • public int AddSeconds(ArrayList myList)
  • int total0
  • DateTime myDate
  • foreach (object myObj in myList)
  • myDate(DateTime) myObj
  • totalmyDate.Second
  • return total

5
Generics
  • Other method is to derive your own collection
    class. Namespace is now cluttered with many
    strongly typed collections
  • Answer to problem GENERICS!!!!!

6
Generics Example
  • System.Collections.Generic
  • private System.Collections.Generic.ListltDateTimegt
    myList
  • private Dictionaryltstring, StackltDateTimegtgt
    myList

7
Generics old example
public int AddSeconds(ListltDateTimegt myList)
int total 0
foreach (DateTime myDate in myList)
total myDate.Second return
total
8
Partial types
  • Easy way to separate automatically generated code
    from your own
  • public partial class myClass
  • public partial class myClass

9
Anonymous methods
  • Review of delegates
  • Anonymous delegatedelegate without a function
    name, just code

10
Anonymous method example
button1.Click delegate MessageBox.Show("Click
") Alternative button1.Clicknew
EventHandler(myButton1_Click) private void
myButton1_Click(object sender, EventArgs e)
MessageBox.Show(Click)
11
Nullable types
  • Motivation
  • Syntax

int? myInt null if
(myInt.HasValue)
//Do stuff here with myInt.Value
else
//It's null int? d1,
fnull Console.WriteLine(f ?? d)
12
Visual Studio 2005 IDE
  • Demo!
Write a Comment
User Comments (0)
About PowerShow.com