C# for Java Programmers

Solutions Fast Track

Strings

  • Strings can be created either by supply or a literal, or via a constructor.

  • Strings are immutable, meaning once they are created they cannot be modified.

  • If a mutable string is required, use the stringBuilder class.

  • The + sign is the concatenation operator.

  • You may precede a string literal with the @ character to specify that its contents are verbatim (this means escape characters are not used).

Flow Control

  • Most flow control statements are identical to their Java counterparts.

  • C# includes the familiar if/else and switch construct, as well as the while, do-while, and for loops.

  • C# also provides the new foreach loop for iteration through arrays and collections.

  • The C# switch statements do not have implicit fall-through; use of the goto keyword is required to move to another case statement.

Arrays

  • Standard C# arrays are identical to their Java counterparts.

  • C# provides two different kinds of multidimensional arrays, rectangular and jagged.

  • A rectangular array has equal dimensions, a jagged array does not.

  • The params keyword can be used to specify that an unknown number of parameters will be passed to a method.

The foreach Statement

  • The foreach statement is a gift from the VB language that helps to iterate through arrays and collections.

  • The elements accessed within the foreach statement are read-only, and cannot be modified.

  • The foreach statement does not work on classes that implemented iterators, only on true...

UNLIMITED FREE ACCESS TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Bar Graph Arrays
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.