C Sharp Web & Internet Programming Group Diana, Aren, Jeff, & Adam, Farrin 5/5/20081CS 311.
-
Upload
alexander-shelton -
Category
Documents
-
view
218 -
download
0
Transcript of C Sharp Web & Internet Programming Group Diana, Aren, Jeff, & Adam, Farrin 5/5/20081CS 311.
C SharpWeb & Internet Programming
GroupDiana, Aren, Jeff, & Adam, Farrin
5/5/2008 1CS 311
Anders Hejlsberg formed a team January 1999
Publicly announced July 2000 Third Version in June 2005
5/5/2008 2CS 311
Visual J++ Turbo Pascal Based on Java Delphi Smalltalk Based on C++ Visual Basic
5/5/2008 3CS 311
Simple General-purpose OOP Ground up design Components High Level Source code Portable Compiled
5/5/2008 4CS 311
Preprocessor directives No Actual preprocessor Symbols but no macros
5/5/2008 5CS 311
Int Long Char Float Bool Double Byte Word
5/5/2008 6CS 311
Implicit conversions Enumeration members are placed in their
own namespace. Type Reflection
5/5/2008 7CS 311
C# supports a strict Boolean type, Bool Conditionals No 1=True Easy conversion If(a=b) mistake
5/5/2008 8CS 311
New features Can be cross-language C++ templates can not Type Constraints No non-typed parameters
5/5/2008 9CS 311
global variables Methods and members shadow variables Similar to C++ and Java Int A=1; string B = Boo;
5/5/2008 10CS 311
Similar to C++ If( Bool){} While(Bool){}
5/5/2008 11CS 311
No Global functions All method and member functions must
be declared within classes
C# pointers Managed memory Garbage collected
5/5/2008 12CS 311
Similar to C++ class example_class { { //
implementation } } All methods and members Multiple Inheritance
5/5/2008 13CS 311
5/5/2008 14CS 311
Allows class implementation across more than one source file.
file1.cs: public partial class MyClass { public
MyClass() { // implementation } } file2.cs: public partial class MyClass { public void
SomeMethod() { // implementation } }
Light weight classes Allocated on stack
5/5/2008 15CS 311
A dynamic linking library(s) Shared Libraries
5/5/2008 16CS 311
// File: Add.cs namespace UtilityMethods { public class AddClass { public static long Add(long i, long j) { return (i + j); } } }
namespace UtilityMethods { public class MultiplyClass { public static long Multiply(long x, long y) { return (x * y); } } }
5/5/2008 17CS 311
// File: TestCode.cs using UtilityMethods; class TestCode { static void Main(string[] args) { System.Console.WriteLine("Calling methods from MathLibrary.DLL:");
if (args.Length != 2) { System.Console.WriteLine("Usage: TestCode
<num1> <num2>"); return; } long num1 = long.Parse(args[0]);
} }5/5/2008 18CS 311
New int foo = 42; // Value type... object bar =
foo; // foo is boxed to bar. int foo = 42; // Value type. object bar =
foo; // foo is boxed to bar. int foo2 = (int)bar; // Unboxed back to value type.
5/5/2008 19CS 311
August 2000 Specs submitted + CLI ISO Standard 2003 June 2005 third edition Approved
5/5/2008 20CS 311
using System; // A "Hello World!" program in C#
namespace Hello World { class Hello { static void Main()
{ System.Console.WriteLine("Hello World!");
} } }
5/5/2008 21CS 311
// /* */ XML documentation
5/5/2008 22CS 311
.NET Only available on Windows Greater resources required Nonstandard classes
5/5/2008 23CS 311
www.en.wikipedia.com\c-sharp.html http://msdn.microsoft.com/vcsharp/ http://msdn2.microsoft.com/en-us/library/
67ef8sbd(VS.80).aspx http://msdn2.microsoft.com/en-us/vcshar
p/aa336809.aspx http://standards.iso.org/ittf/PubliclyAvaila
bleStandards/c042926_ISO_IEC_23270_2006(E).zip
5/5/2008 24CS 311
New file1.cs: public partial class MyClass { public
MyClass() { // implementation } } file2.cs: public partial class MyClass { public void
SomeMethod() { // implementation } }
5/5/2008 25CS 311
No Global functions All method and member functions must
be declared within classes
5/5/2008 26CS 311
// Method that takes an iterable input (possibly an array) and returns all even numbers.
public static IEnumerable<int> GetEven(IEnumerable<int> numbers)
{ foreach (int i in numbers) { if (i % 2 == 0) yield return i; } }
5/5/2008 27CS 311