Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas


Introdução à Programação C#: Exemplos e Conceitos, Notas de estudo de Informática

Os conceitos básicos da programação c#, incluindo declarações de variáveis, tipos de dados, operadores aritméticos, manipulação de strings, controles de fluxo e estruturas de dados. Além disso, fornece exemplos práticos para ilustrar cada conceito.

Tipologia: Notas de estudo

Antes de 2010

Compartilhado em 10/11/2010

alexandre-ferreira-leite-4
alexandre-ferreira-leite-4 🇧🇷

5

(3)

8 documentos

1 / 1

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
010010100101011010101101001010101001011101011010
Namespace
using Namespace;
Data Types
byte,sbyte,int,uint,short,ushort,long,ulong,float,double,decimal,bool,char,string,
object
Variable Declaration
public | protected internal | protected | internal | private <type> As public | protected internal | protected | internal | private <type> As
<variable_name>
Type Declaration
public | internal | private <variable><suffix>
Suffixes
f -float, l,L - long, No double suffix, U,u - unsigned
Arrays
<type>[] <name> = new <type>[ArraySize];<type>[] <name> = new <type>[ArraySize];
Initialize Array
<type>[] <name> = new <type>[ArraySize] {<value1>, <value2>, ... , <valueN>};
Change Size of Array
<type>[] <name> = new <type>[ArraySize];
Array.Resize<type>(ref <name>, <size>);
Comments
//Comment text//Comment text
Multi-line comments
/* This is commented */
XML Comments
Press the / (forward slash) key 3 times.
Line Continuation
string strtext = @To break a long string across multiple lines,
end the string, add the line continuation characterend the string, add the line continuation character
and continue the string on the next line.;
Arithmetic Operators
+ (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus)
String Concatenation
+
Relational Operators
< (Less Than), <= (Less Than or Equal < (Less Than), <= (Less Than or Equal To), > (Greater Than), >= (Greater Than
or Equal To), == (Equal To),! = (Not Equal To), is, as
Logical Operators
& (And), | (Or), ^ (Xor),&& (AndAlso), || (OrElse)
Assignment Operators
= (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %= = (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %=
(Modulus), &= (And),|= (OR), ^= (Exclusive OR), <<= (Left Shift), >>= (Right
Shift), ??
String Manipulation
.Substring(<start>,[<length>])
.Trim() <trims from beginning & end of string>
.TrimEnd([<char array>])
..TrimStart([char array])
.ToLower() <to lower case>
.ToUpper() <to upper case>
.Replace(<find>,<replace>)
.Equals(<expression>) <6 available overloads>
.Contains(<string>)
.Join(<seperator>,<value>,[<count>])
.Compare(<string1>,<string2>,[<ignore case>]) <7 overloads available>.Compare(<string1>,<string2>,[<ignore case>]) <7 overloads available>
.Copy(<string>)
Error Handling
try
{
//<statements that may cause an error>;
}
catch(Exception ex)catch(Exception ex)
{
//<statements to use when an error occurs>;
}
finally
{
//<statements to use no matter what happens>
}}
If Else
if(expression)
{
<statement 1>;
}
else
{{
<statement 2>;
}
C# version of IIF()
variable == ?true:false;
For Loop
for(statement)
{{
<statement>;
}
For Each Loop
foreach(<variable> In <object>)
{
<statements>;
[break]; [break];
[continue];
}
While Loop
while(<expression>)
{
<statement>
}}
Do-While Loop
do
{
<statement>;
} while <expression>;
Select Case Statement
switch(<expression>)switch(<expression>)
{
case <literal or type>:
<statement>;
<break>;
case <literal or type>:
<statement>;
<break>; <break>;
'
'
default:
<statement>;
<break>;
}
Function StructureFunction Structure
<private, public, protected, internal> [static] <ReturnType>
<Function_Name>([Parameters])
{
//body of the function;
return <ReturnType>;
}
Sub Procedure StructureSub Procedure Structure
<private, public, protected, internal> void <method_name>([Parameters])
{
//body of the procedure;
}
Class Structure
public class <Class_Name>
{{
//body of class
}
public
'method_prototypes
'data_attributes
private
'method_prototypes'method_prototypes
'data_attributes
internal
'method_prototypes
static
'method_prototypes
'data_attributes
Download More Reference Sheets & Get Programming Help @
http://www.DreamInCode.net
Edited By:PsychoCoder, Martyr2
Published: October 9, 2007

Pré-visualização parcial do texto

Baixe Introdução à Programação C#: Exemplos e Conceitos e outras Notas de estudo em PDF para Informática, somente na Docsity!

Namespace using Namespace;

Data Types byte,sbyte,int,uint,short,ushort,long,ulong,float,double,decimal,bool,char,string, object

Variable Declaration public | protected internal | protected | internal | private Aspublic | protected internal | protected | internal | private As <variable_name>

Type Declaration public | internal | private

Suffixes f -float, l,L - long, No double suffix, U,u - unsigned

Arrays [] = new [ArraySize];[] = new [ArraySize];

Initialize Array [] = new [ArraySize] {, , ... , };

Change Size of Array [] = new [ArraySize]; Array.Resize(ref , );

Comments //Comment text//Comment text Multi-line comments /* This is commented */

XML Comments Press the / (forward slash) key 3 times.

Line Continuation string strtext = @“To break a long string across multiple lines, end the string, add the line continuation characterend the string, add the line continuation character and continue the string on the next line.”;

Arithmetic Operators

  • (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus)

String Concatenation

Relational Operators < (Less Than), <= (Less Than or Equal< (Less Than), <= (Less Than or Equal To), > (Greater Than), >= (Greater Than or Equal To), == (Equal To),! = (Not Equal To), is, as

Logical Operators & (And), | (Or), ^ (Xor),&& (AndAlso), || (OrElse)

Assignment Operators = (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %== (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %= (Modulus), &= (And),|= (OR), ^= (Exclusive OR), <<= (Left Shift), >>= (Right Shift), ??

String Manipulation .Substring(,[]) .Trim() <trims from beginning & end of string> .TrimEnd([]) ..TrimStart([char array]) .ToLower() .ToUpper() .Replace(,) .Equals() <6 available overloads> .Contains() .Join(,,[]) .Compare(,,[]) <7 overloads available>.Compare(,,[]) <7 overloads available> .Copy()

Error Handling try { //; } catch(Exception ex)catch(Exception ex) { //; } finally { // }}

If Else if(expression) { <statement 1>; } else {{ <statement 2>; }

C# version of IIF() variable == ?true:false;

For Loop for(statement) {{ ; }

For Each Loop foreach( In ) { ; [break];[break]; [continue]; }

While Loop while() { }}

Do-While Loop do { ; } while ;

Select Case Statement switch()switch() { case : ; ; case : ; ;; ' ' default: ; ; }

Function StructureFunction Structure <private, public, protected, internal> [static] <Function_Name>([Parameters]) { //body of the function; return ; }

Sub Procedure StructureSub Procedure Structure <private, public, protected, internal> void <method_name>([Parameters]) { //body of the procedure; }

Class Structure public class <Class_Name> {{ //body of class }

public 'method_prototypes 'data_attributes private 'method_prototypes'method_prototypes 'data_attributes internal 'method_prototypes static 'method_prototypes 'data_attributes

Download More Reference Sheets & Get Programming Help @

http://www.DreamInCode.net

Edited By:PsychoCoder, Martyr Published: October 9, 2007