<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://smsoft.pl/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Michał Simoniuksztis o programowaniu w .NET</title>
    <link>http://smsoft.pl/</link>
    <description>Blog głównie o programowaniu w .NET, T-SQL  i dziedzinach pokrewnych, które mnie interesują.</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <item>
      <guid isPermaLink="false">1412</guid>
      <link>http://smsoft.pl/blog/ii-implementacja-rozwiazan-infrastructure-as-a-service-czesc-2-arm-templates/</link>
      <category>Exam AZ-204</category>
      <title>II. Implementacja rozwiązań Infrastructure as a service część 2 - ARM templates</title>
      <description>&lt;p&gt;&lt;strong&gt;Implementacja rozwiązań IaaS&lt;/strong&gt; jest częścią tematu &lt;strong&gt;Develop Azure compute solutions&lt;/strong&gt; egzaminu &lt;strong&gt;AZ-204&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Umiejętności badane w tej części egzaminu:
* Uruchamianie maszyn wirtualnych (&lt;strong&gt;VM&lt;/strong&gt;)
* &lt;strong&gt;Konfiguracja, walidacja i wdrażanie &lt;em&gt;*szablonów ARM&lt;/em&gt;*&lt;/strong&gt;
* Konfiguracja obrazów kontenerów 
* Publikacja obrazów w &lt;strong&gt;Azure Container Registry&lt;/strong&gt;
* Uruchamianie kontenerów za pomocą &lt;strong&gt;Azure Container Instance&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;1. Szablony ARM&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Szablon ARM&lt;/strong&gt; to plik w formacie &lt;em&gt;JSON&lt;/em&gt;, który jest dokumentem konfiguracyjnym definiującym zasoby, które mają zostać wdrożone na &lt;em&gt;platformie Azure&lt;/em&gt; wraz z ich konfiguracjami. Za pomocą &lt;strong&gt;szablonu ARM&lt;/strong&gt; można utworzyć dowolny zasób.
&lt;strong&gt;Szablony ARM&lt;/strong&gt; są podstawowym elementem automatyzacji wdrażania infrastruktury &lt;em&gt;Azure&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Korzystając z &lt;strong&gt;szablonów ARM&lt;/strong&gt;, można sparametryzować elementy konfiguracji dla zasobów zdefiniowanych w szablonie. Można użyć parametrów dla często zmienianych elementów konfiguracji, takich jak nazwy maszyn wirtualnych, nazwy sieci wirtualnych itd. Można następnie użyć tego samego &lt;strong&gt;szablonu ARM&lt;/strong&gt; wielokrotnie używając różnych parametrów, aby wdrożyć różne środowiska np. inny zestaw parametrów dla produkcji i inny dla QA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Szablon ARM&lt;/strong&gt; można skompilować i wyeksportować z &lt;em&gt;portalu Azure&lt;/em&gt; lub napisać ręcznie. Ponadto można zacząć od kolekcji szablonów szybkiego startu dostępnych w &lt;em&gt;Azure Portal&lt;/em&gt; w bloku wdrażania niestandardowego.&lt;/p&gt;

&lt;h2&gt;2. Wdrażanie szablonów ARM:&lt;/h2&gt;

&lt;p&gt;Po utworzeniu &lt;strong&gt;szablonu ARM&lt;/strong&gt; przesyłamy go do usługi &lt;strong&gt;Azure Resource Manager&lt;/strong&gt;. &lt;strong&gt;Resource Manager&lt;/strong&gt; odbiera szablon w postaci pliku &lt;em&gt;JSON&lt;/em&gt;, a następnie konwertuje go na operacje interfejsu &lt;em&gt;REST API&lt;/em&gt;.
W celu wdrożenia możemy użyć różnych narzędzi a w tym: 
* &lt;strong&gt;Azure Portal&lt;/strong&gt;
* &lt;strong&gt;Azure CLI&lt;/strong&gt;
* &lt;strong&gt;PowerShell (Az Module)&lt;/strong&gt;
* &lt;strong&gt;REST API&lt;/strong&gt;
* &lt;strong&gt;Azure Cloud Shell&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;3. Format szablonu ARM&lt;/h2&gt;

&lt;p&gt;W swojej najprostszej strukturze szablon składa się z następujących elementów:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;powershell
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/.
deploymentTemplate.json#",
"contentVersion": "",
"apiProfile": "",
"parameters": { },
"variables": { },
"functions": [ ],
"resources": [ ],
"outputs": { }
}
&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;$schema&lt;/strong&gt; - Lokalizacja schematu JSON opisującego wersję języka szablonu.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;contentVersion&lt;/strong&gt; - Wersja szablonu (np. 1.0.0.0). Można użyć dowolną wartość, aby udokumentować znaczące zmiany w szablonie.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;apiProfile&lt;/strong&gt; - Wersja interfejsu API, która służy jako kolekcja wersji interfejsu API dla typów zasobów. Użyj tej wartości, aby uniknąć konieczności określania wersji interfejsu API dla każdego zasobu w szablonie. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;parameters&lt;/strong&gt; - Wartości parametrów podawane podczas wdrażania w celu dostosowania zasobów.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;variables&lt;/strong&gt; - Wartości używane jako fragmenty JSON w szablonie w celu uproszczenia wyrażeń języka szablonu.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;functions&lt;/strong&gt; - Funkcje zdefiniowane przez użytkownika, które są dostępne w szablonie.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;resources&lt;/strong&gt; - Typy zasobów, które są wdrażane lub aktualizowane w grupie zasobów lub subskrypcji.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;outputs&lt;/strong&gt; - Wartości zwracane po wdrożeniu.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Więcej na temat struktury i składni mozna przeczytać na stronie: &lt;a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/syntax"&gt;Struktura i składnia szablonu ARM&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;4. Demo - Pobranie szablonu ARM maszyny wirtualnej z portalu Azure:&lt;/h2&gt;

&lt;p&gt;Aby utworzyć &lt;strong&gt;szablon ARM&lt;/strong&gt;, zamiast tworzyć go od początku ręcznie, możemy go utworzyć w &lt;strong&gt;Azure Portal&lt;/strong&gt;. Następnie możemy go pobrać, dodać do biblioteki lub wdrożyć.&lt;/p&gt;

&lt;p&gt;Aby utworzyć &lt;strong&gt;szablon ARM&lt;/strong&gt;, zaczynamy od utworzenia maszyny wirtualnej w &lt;strong&gt;Azure Portal&lt;/strong&gt;, ale zamiast tworzyć maszynę wirtualną, eksportujemy &lt;strong&gt;szablon ARM&lt;/strong&gt; dla tego wdrożenia (proces ten jest podobny dla większości zasobów na platformie &lt;em&gt;Azure&lt;/em&gt;).
Proces tworzenia maszyny wirtualnej w &lt;strong&gt;Azure Portal&lt;/strong&gt; był opisany w poprzednim wpisie z tej serii (&lt;a href="http://www.smsoft.pl/blog/i-implementacja-rozwiazan-infrastructure-as-a-service-czesc-1-maszyny-wirtualne/"&gt;Implementacja-rozwiazan-infrastructure-as-a-service-czesc-1-maszyny-wirtualne&lt;/a&gt;). &lt;/p&gt;

&lt;p&gt;Po kliknięciu guzika &lt;strong&gt;Przeglądanie + tworzenie&lt;/strong&gt;, zamiast kliknąć guzik &lt;strong&gt;Utwórz&lt;/strong&gt; wybieramy &lt;strong&gt;Pobierz szablon do automatyzacji&lt;/strong&gt;. Spowoduje to utworzenie plików JSON szablonu i parametrów potrzebnych do wdrożenia opartego na szablonie ARM dla właśnie skonfigurowanej maszyny wirtualnej.&lt;/p&gt;

&lt;p&gt;Na tym ekranie w górnym menu możemy kliknąć &lt;strong&gt;Pobierz&lt;/strong&gt;, aby pobrać pliki szablonów i parametrów, możemy kliknąć &lt;strong&gt;Dodaj do biblioteki&lt;/strong&gt;, aby dodać je do biblioteki w celu dalszych wdrożeń, lub możemy je wdrożyć bezpośrednio z tego miejsca za pomocą guzika &lt;strong&gt;Wdróż&lt;/strong&gt;. Dodatkowo możemy zbadać utworzone pliki w oknie poniżej:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/ijegprgm/vm-create-arm-template.png" alt="arm-template" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pliki wygenerowanego szablonu dostępne są tutaj:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/michalsimon/Exam-AZ-204/blob/main/src/IaaS/vm-template/parameters.json"&gt;parameters.json&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/michalsimon/Exam-AZ-204/blob/main/src/IaaS/vm-template/template.json"&gt;template.json&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Schema:&lt;/strong&gt;
&lt;code&gt;json
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ContentVersion:&lt;/strong&gt;
&lt;code&gt;json
"contentVersion": "1.0.0.0",
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters:&lt;/strong&gt;
&lt;code&gt;json
"parameters": {
        "location": {
            "type": "string"
        },
        "networkInterfaceName": {
            "type": "string"
        },
        "networkSecurityGroupName": {
            "type": "string"
        }
        #...
    }
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variables:&lt;/strong&gt;
&lt;code&gt;json
"variables": {
        "nsgId": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]",
        "vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
        "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
    }
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;
&lt;code&gt;json
"resources": [
        {
            "name": "[parameters('networkInterfaceName')]",
            "type": "Microsoft.Network/networkInterfaces",
            #...
        },
        {
            "name": "[parameters('networkSecurityGroupName')]",
            "type": "Microsoft.Network/networkSecurityGroups",
            #...
        },
        {
            "name": "[parameters('virtualNetworkName')]",
            "type": "Microsoft.Network/virtualNetworks",
            #...
        },
        {
            "name": "[parameters('publicIpAddressName')]",
            "type": "Microsoft.Network/publicIpAddresses",
            #...
        },
        {
            "name": "[parameters('virtualMachineName')]",
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2020-06-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
            ],
            "properties": {
                #...
            }
        }
    ]
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Outputs:&lt;/strong&gt;
&lt;code&gt;json
"outputs": {
        "adminUsername": {
            "type": "string",
            "value": "[parameters('adminUsername')]"
        }
    }
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;5. Demo - wdrożenie szablonu ARM maszyny wirtualnej:&lt;/h2&gt;

&lt;p&gt;Plik ze skryptem wdrożenia dostępny jest tutaj: &lt;a href="https://github.com/michalsimon/Exam-AZ-204/blob/main/src/IaaS/deploy-win-vm-arm-template-by-azure-powershell.ps1"&gt;deploy-win-vm-arm-template-by-azure-powershell.ps1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Przed wdrożeniem należy ustawić parametr &lt;strong&gt;adminPassword&lt;/strong&gt; w pliku &lt;strong&gt;parameters.json&lt;/strong&gt;.
```powershell&lt;/p&gt;

&lt;h1&gt;Login and set a subscription&lt;/h1&gt;

&lt;p&gt;Connect-AzAccount -SubscriptionName 'BizSpark'
Set-AzContext -SubscriptionName 'BizSpark'&lt;/p&gt;

&lt;h1&gt;Create a Resource Group&lt;/h1&gt;

&lt;p&gt;New-AzResourceGroup -Name "iaas-demo-rg" -Location "WestEurope"&lt;/p&gt;

&lt;h1&gt;Deploy ARM Template&lt;/h1&gt;

&lt;p&gt;New-AzResourceGroupDeployment &lt;code&gt;
    -Name mydeployment -ResourceGroupName 'iaas-demo-rg'&lt;/code&gt;
    -TemplateFile './vm-template/template.json' `
    -TemplateParameterFile './vm-template/parameters.json'
```&lt;/p&gt;</description>
      <pubDate>Fri, 15 Oct 2021 16:36:25 +0200</pubDate>
      <a10:updated>2021-10-15T16:36:25+02:00</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1411</guid>
      <link>http://smsoft.pl/blog/i-implementacja-rozwiazan-infrastructure-as-a-service-czesc-1-maszyny-wirtualne/</link>
      <category>Exam AZ-204</category>
      <title>I. Implementacja rozwiązań Infrastructure as a service część 1 - Maszyny wirtualne</title>
      <description>&lt;p&gt;&lt;strong&gt;Implementacja rozwiązań IaaS&lt;/strong&gt; jest częścią tematu &lt;strong&gt;Develop Azure compute solutions&lt;/strong&gt; egzaminu &lt;strong&gt;AZ-204&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Umiejętności badane w tej części egzaminu:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Uruchamianie maszyn wirtualnych (VM)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Konfiguracja, walidacja i wdrażanie &lt;strong&gt;szablonów ARM&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Konfiguracja obrazów kontenerów&lt;/li&gt;
&lt;li&gt;Publikacja obrazów w &lt;strong&gt;Azure Container Registry&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Uruchamianie kontenerów za pomocą &lt;strong&gt;Azure Container Instance&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;1. Uruchamianie maszyn wirtualnych&lt;/h2&gt;

&lt;p&gt;Zacznijmy od ogólnego przeglądu tego, z czego składa się maszyna wirtualna.
Maszyny wirtualne platformy Azure (&lt;strong&gt;VMs&lt;/strong&gt;) są wdrażane w &lt;strong&gt;grupach zasobów&lt;/strong&gt; i znajdują się w &lt;strong&gt;regionach&lt;/strong&gt; platformy Azure. Zwykle chcemy umieścić maszynę wirtualną w &lt;strong&gt;regionie&lt;/strong&gt; blisko aplikacji lub użytkowników, którzy będą korzystać z usług wdrożonych na tej maszynie wirtualnej.
Podczas budowania maszyny wirtualnej wybieramy spośród wstępnie skonfigurowanych &lt;strong&gt;rozmiarów maszyn wirtualnych&lt;/strong&gt; na podstawie liczby rdzeni procesora, ilości pamięci RAM, a także różnych możliwości wydajności dysku. Wybrany rozmiar zależy od obciążenia wdrażanego na tej maszynie wirtualnej. Rozmiar maszyny wirtualnej można łatwo zaktualizować lub obniżyć po wdrożeniu maszyny wirtualnej. 
Kolejnym kluczowym elementem wdrażania maszyny wirtualnej jest &lt;strong&gt;połączenie sieciowe&lt;/strong&gt; maszyny wirtualnej z resztą środowiska i w razie potrzeby z Internetem. Kolejnym składnikiem maszyny wirtualnej są &lt;strong&gt;obrazy maszyn wirtualnych&lt;/strong&gt;. Obrazy są podstawowym obrazem używanym do wdrażania na naszej maszynie wirtualnej, najczęściej systemów operacyjnych, takich jak Windows lub Linux. W portalu &lt;em&gt;Azure Marketplace&lt;/em&gt; dostępnych jest wiele różnych obrazów maszyn wirtualnych opartych na wielu różnych systemach operacyjnych z róznymi edycjami, obrazy ze wstępnie skonfigurowanymi aplikacjami oraz sieciowe urządzenia wirtualne. 
Ostatnim składnikiem maszyny wirtualnej jest &lt;strong&gt;pamięć masowa&lt;/strong&gt;. Każda utworzona maszyna wirtualna będzie miała co najmniej jeden dysk wirtualny do obsługi podstawowego systemu operacyjnego. W razie potrzeby można dodać dodatkowe dyski wirtualne w celu obsługi danych aplikacji. &lt;/p&gt;

&lt;h4&gt;Metody tworzenia maszyn wirtualnych na platformie Azure:&lt;/h4&gt;

&lt;p&gt;Podczas tworzenia maszyny wirtualnej na platformie Azure mamy do dyspozycji kilka narzędzi:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Azure Portal&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Azure CLI&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Azure PowerShell (Az Module)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Azure ARM Templates&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;2 Tworzenie maszyny wirtualnej w portalu Azure&lt;/h3&gt;

&lt;p&gt;Aby utworzyć &lt;strong&gt;maszynę wirtualną&lt;/strong&gt; w portalu Azure należy przejść do usługi &lt;strong&gt;Maszyny Wirtualne&lt;/strong&gt; i wcisnąć guzik &lt;strong&gt;utwórz maszynę wirtualną&lt;/strong&gt;.
Na stronie tworzenie maszyny wirtualnej pierwsza sekcja to informacje &lt;strong&gt;Podstawowe&lt;/strong&gt; o tworzonej maszynie. Na górze strony można zobaczyć, że istnieją dodatkowe sekcje dotyczące dysków, sieci, zarządzania itp. Te sekcje umożliwiają tworzenie bardziej niestandardowych konfiguracji, takich jak dodawanie dodatkowych dysków lub dodawanie maszyny wirtualnej do istniejącej sieci wirtualnej, a nawet tworzenie bardziej szczegółowych reguł zabezpieczeń sieci.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/mgsofyxc/vm-portal-details-1.png" alt="vm-details" /&gt;&lt;/p&gt;

&lt;p&gt;W sekcji &lt;strong&gt;Podstawowe&lt;/strong&gt; przypisujemy tworzoną maszynę wirtualną do &lt;strong&gt;subskrypcji&lt;/strong&gt; i do &lt;strong&gt;grupy zasobów&lt;/strong&gt;. Jeśli &lt;strong&gt;grupa zasobów&lt;/strong&gt; nie istnieje to można ją utworzyć. 
Następnie definiujemy szczegóły instancji, w której nadajemy maszynie wirtualnej &lt;strong&gt;nazwę&lt;/strong&gt; i wybieramy &lt;strong&gt;region&lt;/strong&gt;, w którym chcemy wdrożyć maszynę wirtualną. Następnie, opcjonalnie, możemy określić zestawy i strefy dostępności. Następnie wybierzemy &lt;strong&gt;obraz maszyny wirtualnej&lt;/strong&gt; z listy obrazów dostępnych w wybranym regionie.&lt;/p&gt;

&lt;p&gt;Kolejna opcja to &lt;strong&gt;Azure Spot&lt;/strong&gt;, która pozwala na użycie maszyny w obniżonej cenie lecz umożliwia platformie Azure zatrzymanie i zwolnienie maszyny wirtualnej, jeśli platforma Azure z dowolnego powodu potrzebuje z powrotem tej pojemności obliczeniowej.&lt;/p&gt;

&lt;p&gt;Następnie definiujemy &lt;strong&gt;rozmiar maszyny wirtualnej&lt;/strong&gt;, w przypadku tej demonstracji wybieramy najniższy z naszej listy rozmiarów maszyn wirtualnych dostępnych w regionie.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/opbo3z0v/vm-portal-details-2.png" alt="vm-details" /&gt;&lt;/p&gt;

&lt;p&gt;W sekcji &lt;strong&gt;Konto administratora&lt;/strong&gt; definiujemy wymagane informacje dotyczące dostępu administracyjnego do maszyny wirtualnej. W systemie Windows jest to nazwa użytkownika i hasło, a w systemie Linux może to być nazwa użytkownika i hasło lub klucz publiczny SSH.&lt;/p&gt;

&lt;p&gt;Na koniec definiujemy kilka &lt;strong&gt;reguł portów przychodzących&lt;/strong&gt;, aby uzyskać dostęp do tej maszyny wirtualnej. W konfiguracji domyślnej maszyna wirtualna otrzyma publiczny adres IP w celu uzyskania dostępu do tej maszyny wirtualnej przez Internet. Ale domyślnie dostęp spoza sieci wirtualnej lub Internetu nie jest dozwolony. Dodanie tutaj reguł portów przychodzących jest sposobem na zezwolenie na dostęp sieciowy do maszyny wirtualnej poprzez określenie, które porty przychodzące chcemy otworzyć. Wybranie portu przychodzącego w tym miejscu doda regułę do grupy zabezpieczeń sieci, umożliwiając dostęp z dowolnego adresu IP na określonym porcie. Ponieważ jest to maszyna wirtualna Windows i chcemy uzyskać do niej zdalny dostęp, otworzymy protokuł RDP na porcie 3389. Pozwoli to na dostęp RDP do tej maszyny wirtualnej na tym porcie z dowolnego adresu IP. Możemy również dodać inne porty, takie jak 80 dla HTTP, 443 dla HTTPS i port 22 dla dostępu SSH do maszyny wirtualnej.&lt;/p&gt;

&lt;p&gt;Dane do wprowadzenia w sekcji &lt;strong&gt;Podstawowe&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;| Sekcja       | Wartość       |
|:----------------|:---------------|
| Subskrypcja | &lt;em&gt;{subscription_name}&lt;/em&gt; |
| Grupa zasobów | &lt;em&gt;(new) iaas-demo-rg&lt;/em&gt; |
| Nazwa maszyny wirtualnej | &lt;em&gt;iaas-demo-win&lt;/em&gt; |
| Region | &lt;em&gt;Europa Zachodnia&lt;/em&gt; |
| Opcje dostępności | &lt;em&gt;Nie jest wymagana żadna nadmiarowość infrastruktury&lt;/em&gt; |
| Obraz | &lt;em&gt;Windows server 2019 Datacenter - Gen1&lt;/em&gt; |
| Rozmiar | &lt;em&gt;Standard_DS1_v2&lt;/em&gt; |
| Username | &lt;em&gt;iaas-demo-win-user&lt;/em&gt; |
| Password | &lt;em&gt;{jakieś-hasło}&lt;/em&gt; |
| Publiczne porty ruchu przychodzącego | &lt;em&gt;Zezwalaj na wybrane porty&lt;/em&gt; |
| Wybierz porty wejściowe | &lt;em&gt;RDP (3389)&lt;/em&gt; |
| &lt;strong&gt;Przeglądanie + tworzenie&lt;/strong&gt; |  |&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Widok w trakcie wdrażania maszyny:&lt;/strong&gt;
&lt;img src="http://smsoft.pl/media/gpic33p2/vm-portal-success.png" alt="vm-success" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Widok detali utworzonej maszyny wirtualnej:&lt;/strong&gt;
&lt;img src="http://smsoft.pl/media/4wjiiiu1/vm-portal-vm-view.png" alt="enter image description here" /&gt;&lt;/p&gt;

&lt;p&gt;Aby połączyć się do maszyny za pomocą protokołu RDP wybieramy guzik &lt;strong&gt;Połącz&lt;/strong&gt; z górnego menu na stronie detali maszyny wirtualnej i pobieramy plik RDP:
&lt;img src="http://smsoft.pl/media/4cuesifp/vm-portal-vm-view-rdp-connect.png" alt="enter image description here" /&gt;&lt;/p&gt;

&lt;h3&gt;3 Tworzenie maszyny wirtualnej w kodzie&lt;/h3&gt;

&lt;p&gt;Jako programiści jesteś przyzwyczajony do pisania kodu do tworzenia aplikacji. Na platformie Azure istnieje możliwość tworzenia maszyn wirtualnych i infrastruktury przy użyciu kodu. A wdrażanie infrastruktury, takiej jak maszyny wirtualne z kodem, zapewnia Twojej organizacji dużą wartość:
* wdrażanie maszyn wirtualnych z kodem zwiększa spójność wdrożeń i tworzenia maszyn wirtualnych, dzięki czemu można za każdym razem tworzyć wiele maszyn wirtualnych w ten sam sposób. 
* jak każdy inny kod, kod infrastruktury można umieścić w repozutorium kodu źródłowego takim jak np. GIT. 
* kod infrastruktury może być użyty do wdrażania systemów produkcyjnych z wykorzystaniem automatyzacji. 
* dzięki wdrożeniom w kodzie, możesz wykorzystać ten kod do konstruowania podobnych środowisk takich jak DEV/TEST/STG.&lt;/p&gt;

&lt;p&gt;Niezależnie od tego, czy tworzymy maszynę wirtualną za pomocą interfejsu wiersza polecenia platformy Azure, czy programu Azure PowerShell z modułem Az, proces tworzenia maszyny wirtualnej w kodzie składa się z tych samych kroków:
1. Logowanie i ustawienie aktywnej subskrypcji
2. Tworzenie grupy zasobów (resource group)
3. Tworzenie maszyny wirtualnej (VM)
4. Udostępnienie portu dostępu zdalnego (w systemie Windows jest to port TCP 3389. W przypadku RDP i Linux jest to port TCP 22 dla SSH.)
5. Pobranie publicznego adresu IP&lt;/p&gt;

&lt;h4&gt;3.1 Tworzenie maszyny wirtualnej za pomocą Azure CLI&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Logowanie i ustawienie aktywnej subskrypcji&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Za pomocą polecenia &lt;code&gt;az login&lt;/code&gt; logujemy się na konto Azure. Po uruchomieniu polecenia uruchomi się przeglądarka internetowa z dialogiem logowania do konta Azure.&lt;/p&gt;

&lt;p&gt;Za pomocą polecenia &lt;code&gt;az account set --subscription&lt;/code&gt; ustawiamy aktywną subskrypcję.&lt;/p&gt;

&lt;p&gt;```powershell&lt;/p&gt;

&lt;h1&gt;Login and set a subscription&lt;/h1&gt;

&lt;p&gt;az login
az account set --subscription "&lt;SUBSCRIPTION_NAME&gt;"
```&lt;/p&gt;

&lt;ol start="2"&gt;
&lt;li&gt;Tworzenie grupy zasobów&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Możemy utworzyć grupę zasobów za pomocą polecenia Azure CLI: &lt;code&gt;az group create&lt;/code&gt;. Nadajemy tej grupie zasobów nazwę, wybieramy lokalizację w której chcemy utworzyć grupę zasobów. Możemy też oczywiście wdrożyć maszynę wirtualną w już istniejącej grupie zasobów.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;powershell
az group create \
--name "iaas-demo-rg" \
--location "westeurope"
&lt;/code&gt;&lt;/p&gt;

&lt;ol start="3"&gt;
&lt;li&gt;Tworzenie maszyny wirtualnej
Możemy utworzyć maszynę wirtualną za pomocą polecenia Azure CLI: &lt;code&gt;az vm create&lt;/code&gt;. Jako parametry dodajemy nazwę grupy zasobów, nazwę maszyny wirtualnej, obraz systemu oraz dane uwierzytelniające służące do zalogowania się do systemu. Procedura różni się nieco dla systemów Windows i Linux.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Obraz maszyny wirtualnej &lt;em&gt;Windows 2019 Server Datacenter&lt;/em&gt; to &lt;em&gt;win2019datacenter&lt;/em&gt;. Kolejne dwa parametry definiują nazwę użytkownika administratora i hasło administratora. Ponieważ jest to Windows, to konto będzie lokalnym kontem administratora, którego można użyć do zalogowania się do maszyny wirtualnej za pierwszym razem.
Możesz określić rozmiar maszyny wirtualnej za pomocą parametru o nazwie &lt;em&gt;size&lt;/em&gt;. Jeśli nic nie zostanie wybrane to domyślnie otrzymamy maszynę wirtualną &lt;em&gt;Standard Ds1 v2&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;powershell
az vm create \
--resource-group "iaas-demo-rg" \
--name "iaas-demo-win" \
--image "win2019datacenter" \
--admin-username "iaasdemoadmin" \
--admin-password "iaasdemoadmin123$%^"
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Jeśli chcemy utworzyć maszynę wirtualną z Linuksem, wzorzec jest bardzo podobny. Jako obraz Linuksa możemy wybrać Ubuntu LTS.
Możemy zmienić typ uwierzytelniania dla tej maszyny wirtualnej na ssh (domyślnym jest hasło).  Lokalizacja tego klucza pochodzi z pliku na dysku lokalnym.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;powershell
az vm create \
--resource-group "iaas-demo-rg" \
--name "iaas-demo-linux" \
--image "UbuntuLTS" \
--admin-username "iaasdemoadmin" \
--authentication-type "ssh" \
--ssh-key-value ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Powyższe dwa przykłady pokaują minimalne parametry potrzebne do utworzenia maszyny wirtualnej za pomocą Azure CLI. Dostępnych jest wiele innych opcji, takich jak dołączenie maszyny wirtualnej do już istniejącej sieci wirtualnej lub sieciowej grupy zabezpieczeń.&lt;/p&gt;

&lt;ol start="4"&gt;
&lt;li&gt;Udostępnienie portu dostępu zdalnego&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Polecenie otwierające port dostępu zdalnego to &lt;code&gt;az vm open-port&lt;/code&gt;. Należy określić nazwę grupy zasobów, nazwę maszyny wirtualnej oraz port, który chcemy otworzyć. 
To polecenie doda regułę otwierania portu (3389 dla Windows lub 22 dla SSH w Linuxie) w sieciowej grupie zabezpieczeń, do której jest dołączona jest maszyna wirtualna. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;
&lt;code&gt;powershell
az vm open-port \
--resource-group "iaas-demo-rg" \
--name "iaas-demo-win" \
--port "3389"
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;
&lt;code&gt;powershell
az vm open-port \
--resource-group "iaas-demo-rg" \
--name "iaas-demo-linux" \
--port "22"
&lt;/code&gt;&lt;/p&gt;

&lt;ol start="5"&gt;
&lt;li&gt;Pobranie publicznego adresu IP
Aby pobrać publiczny adres IP za pomocą Azure CLI używamy polecenia &lt;code&gt;az vm list-ip-addresses&lt;/code&gt;. Za pomocą tego polecenia określasz nazwę grupy zasobów i nazwę maszyny wirtualnej. Spowoduje to wyświetlenie publicznego adresu IP powiązanego z określoną maszyną wirtualną.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;powershell
az vm list-ip-addresses \
--resource-group "iaas-demo-rg" \
--name "iaas-demo-win"
&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;Kod demo:&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/michalsimon/Exam-AZ-204/blob/main/src/IaaS/create-win-vm-by-azure-cli.ps1"&gt;create-win-vm-by-azure-cli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/michalsimon/Exam-AZ-204/blob/main/src/IaaS/create-linux-vm-by-azure-cli.ps1"&gt;create-linux-vm-by-azure-cli&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;3.2 Tworzenie maszyny wirtualnej za pomocą Azure Power Shell&lt;/h4&gt;

&lt;p&gt;Logicznie proces tworzenia maszyny wirtualnej jest taki sam jak dla Azure CLI.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Logowanie i ustawienie aktywnej subskrypcji:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Za pomocą polecenia &lt;code&gt;Connect-AzAccount&lt;/code&gt; logujemy się na konto Azure. Po uruchomieniu polecenia uruchomi się przeglądarka internetowa z dialogiem logowania do konta Azure.&lt;/p&gt;

&lt;p&gt;Za pomocą polecenia &lt;code&gt;Set-AzContext -SubscriptionName&lt;/code&gt; ustawiamy aktywną subskrypcję.&lt;/p&gt;

&lt;p&gt;```powershell&lt;/p&gt;

&lt;h1&gt;Login and set a subscription&lt;/h1&gt;

&lt;p&gt;Connect-AzAccount -SubscriptionName 'BizSpark'
Set-AzContext -SubscriptionName 'BizSpark'
```&lt;/p&gt;

&lt;ol start="2"&gt;
&lt;li&gt;Tworzenie grupy zasobów&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Grupę zasobów tworzymy za pomocą polecenia: &lt;code&gt;New-AzResourceGroup&lt;/code&gt;. Nadajemy tej grupie zasobów nazwę i wybieramy lokalizację.&lt;/p&gt;

&lt;p&gt;```powershell&lt;/p&gt;

&lt;h1&gt;Create a Resource Group&lt;/h1&gt;

&lt;p&gt;New-AzResourceGroup -Name "iaas-demo-rg" -Location "WestEurope"
```&lt;/p&gt;

&lt;ol start="3"&gt;
&lt;li&gt;Tworzenie maszyny wirtualnej i udostępnienie portu dostępu zdalnego&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Krokiem wymaganym do utworzenia maszyny wirtualnej w programie PowerShell jest utworzenie obiektu &lt;em&gt;PSCredential&lt;/em&gt;, który będzie zawierał nazwę użytkownika i hasło używane do poświadczeń konta administratora lokalnego na wdrażanej maszynie wirtualnej. Obiekt &lt;em&gt;PSCredential&lt;/em&gt; definiujemy z nazwą użytkownika i hasłem skonwertowanym na bezpieczny ciąg jako parametrami wejściowymi. Aby skonwertować hasło na bezpieczny ciąg używamy polecenia &lt;code&gt;ConvertTo-SecureString&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Polecenie &lt;em&gt;New-AzVM&lt;/em&gt; tworzy maszynę wirtualną na platformie Azure. Jako parametry definiujemy nazwę grupy zasobów, nazwę maszyny wirtualnej i Credential.
W ramach procesu tworzenia maszyny wirtualnej, za pomocą parametru &lt;em&gt;OpenPorts&lt;/em&gt;, możemy określić porty które mają być otwarte na maszynie wirtualnej.&lt;/p&gt;

&lt;p&gt;```powershell&lt;/p&gt;

&lt;h1&gt;Create a VM credentials&lt;/h1&gt;

&lt;p&gt;$username = 'iaasdemoadmin'
$password = ConvertTo-SecureString 'iaasdemoadmin123$%^' -AsPlainText -Force
$WindowsCred = New-Object System.Management.Automation.PSCredential ($username, $password)&lt;/p&gt;

&lt;h1&gt;Create a Windows VM&lt;/h1&gt;

&lt;p&gt;New-AzVM &lt;code&gt;
    -ResourceGroupName 'iaas-demo-rg'&lt;/code&gt;
    -Name 'iaas-demo-win' &lt;code&gt;
    -Image 'Win2019Datacenter'&lt;/code&gt;
    -Credential $WindowsCred `
    -OpenPorts 3389
```&lt;/p&gt;

&lt;ol start="5"&gt;
&lt;li&gt;Pobranie publicznego adresu IP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Aby pobrać publiczny adres IP można użyć polecenia &lt;code&gt;Get‑AzPublicIpAddress&lt;/code&gt;, a następnie określić nazwę grupy zasobów i nazwę maszyny wirtualnej i użyć &lt;code&gt;Select-Object&lt;/code&gt;, aby zwrócić tylko pole &lt;code&gt;IpAddress&lt;/code&gt; ze zwróconego obiektu.&lt;/p&gt;

&lt;p&gt;```powershell&lt;/p&gt;

&lt;h1&gt;Get the Public IP&lt;/h1&gt;

&lt;p&gt;Get-AzPublicIpAddress &lt;code&gt;
    -ResourceGroupName 'iaas-demo-rg'&lt;/code&gt;
    -Name 'iaas-demo-win' | Select-Object IpAddress
```&lt;/p&gt;

&lt;h4&gt;Kod demo:&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/michalsimon/Exam-AZ-204/blob/main/src/IaaS/create-win-vm-by-azure-powershell.ps1"&gt;create-win-vm-by-azure-powershell&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 15 Oct 2021 16:28:25 +0200</pubDate>
      <a10:updated>2021-10-15T16:28:25+02:00</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1403</guid>
      <link>http://smsoft.pl/blog/import-danych-z-pliku-csv-do-bazy-danych-postgres-za-pomoca-aws-glue-i-s3-bucket/</link>
      <category>AWS</category>
      <title>Import danych z pliku CSV do bazy danych Postgres za pomocą AWS Glue i S3 bucket</title>
      <description>&lt;p&gt;Import danych do bazy danych jest częstym zadaniem programisty. Niestety zadanie to często niesie ze sobą wiele wyzwań i obejmuje wiele dodatkowych zadań takich jak odkrywanie i wydobywanie danych z różnych źródeł, sprawdzanie poprawności, wzbogacanie, czyszczenie, normalizowanie i łączenie danych oraz ładowanie i organizowanie danych w bazach lub hurtowniach danych. Dodatkowym problemem jest często duży wolumen danych które muszą zostać zaimportowane.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; rozwiązuje część z tych problemów.&lt;/p&gt;

&lt;h2&gt;AWS Glue&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; jest bezserwerową usługą integracji danych, która ułatwia odkrywanie, przygotowywanie i łączenie danych na potrzeby analiz, uczenia maszynowego i tworzenia aplikacji. &lt;strong&gt;AWS Glue&lt;/strong&gt; zapewnia wszystkie możliwości potrzebne do integracji danych, dzięki czemu możesz rozpocząć analizę danych i oddanie ich do użytku w ciągu kilku minut, a nie miesięcy.&lt;/p&gt;

&lt;h2&gt;Praca z AWS Glue&lt;/h2&gt;

&lt;p&gt;Praca z &lt;strong&gt;AWS Glue&lt;/strong&gt; składa się z trzech etapów.
W pierwszym etapie &lt;strong&gt;AWS Glue&lt;/strong&gt; odkrywa schemat danych do zaimportowania i zapisuje go do tabeli w &lt;strong&gt;AWS Glue Data Catalog&lt;/strong&gt;. Zadanie to wykonywane jest poprzez &lt;strong&gt;crowlera&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;W drugim etapie, na podstawie wygenerowanego schematu, &lt;strong&gt;AWS Glue&lt;/strong&gt; wygeneruje skrypt zadania &lt;strong&gt;ETL job&lt;/strong&gt;, które zaimportuje dane ze źródła, przekształci je i zapisze do miejsca docelowego.&lt;/p&gt;

&lt;p&gt;Trzecim zadaniem &lt;strong&gt;AWS Glue&lt;/strong&gt; jest uruchomienie wykonania utworzonego zadania, na podstawie wygenerowanego schematu i skryptu zadania. &lt;/p&gt;

&lt;h2&gt;Import danych z pliku CSV do bazy danych Postgres&lt;/h2&gt;

&lt;h3&gt;1. Przygotowanie importowanego pliku&lt;/h3&gt;

&lt;p&gt;Jako przykładowy plik do importu użyty został plik &lt;em&gt;title.basics.csv&lt;/em&gt; z tytułami filmów z bazy portalu &lt;em&gt;IMDb&lt;/em&gt;, który pobrać można ze strony &lt;a href="https://datasets.imdbws.com/"&gt;plików z danymi IMDb&lt;/a&gt;, dzięki uprzejmości IMDb (http://www.imdb.com). Używane za zgodą.&lt;/p&gt;

&lt;p&gt;Pierwsze 10 wierszy z pliku wygląda następująco:
&lt;code&gt;
tconst;titleType;primaryTitle;originalTitle;isAdult;startYear;endYear;runtimeMinutes;genres
tt0000001;short;Carmencita;Carmencita;0;1894;\N;1;Documentary,Short
tt0000002;short;Le clown et ses chiens;Le clown et ses chiens;0;1892;\N;5;Animation,Short
tt0000003;short;Pauvre Pierrot;Pauvre Pierrot;0;1892;\N;4;Animation,Comedy,Romance
tt0000004;short;Un bon bock;Un bon bock;0;1892;\N;12;Animation,Short
tt0000005;short;Blacksmith Scene;Blacksmith Scene;0;1893;\N;1;Comedy,Short
tt0000006;short;Chinese Opium Den;Chinese Opium Den;0;1894;\N;1;Short
tt0000007;short;Corbett and Courtney Before the Kinetograph;Corbett and Courtney Before the Kinetograph;0;1894;\N;1;Short,Sport
tt0000008;short;Edison Kinetoscopic Record of a Sneeze;Edison Kinetoscopic Record of a Sneeze;0;1894;\N;1;Documentary,Short
tt0000009;short;Miss Jerry;Miss Jerry;0;1894;\N;40;Romance,Short
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;PLik &lt;em&gt;title.basics.csv&lt;/em&gt; został umieszczony na &lt;strong&gt;S3 Bucket&lt;/strong&gt; o nazwie &lt;em&gt;imdb-glue&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/nl4hodhi/imdb-glue-bucket.jpg" alt="IMDB Glue Bucket" /&gt;&lt;/p&gt;

&lt;h3&gt;2. Utworzenie crawlera&lt;/h3&gt;

&lt;p&gt;Aby utworzyć &lt;strong&gt;crawlera&lt;/strong&gt; w oknie &lt;strong&gt;AWS Glue&lt;/strong&gt; wybieramy sekcję &lt;strong&gt;Crawlers&lt;/strong&gt; i &lt;strong&gt;Add crawler&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;W pierwszym kroku kreatora tworzącego nowego &lt;strong&gt;crawlera&lt;/strong&gt; definiujemy jego nazwę:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/zzmb2kvm/crawler-info.jpg" alt="Crawler info" /&gt;&lt;/p&gt;

&lt;p&gt;W następnym kroku określamy typ źródła dla &lt;strong&gt;crawlera&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/jcupnx4z/crawler-source-type.jpg" alt="Crawler source type" /&gt;&lt;/p&gt;

&lt;p&gt;W kroku definicji żródła danych wejściowych wybieramy ścieżkę do &lt;strong&gt;S3 bucket&lt;/strong&gt; w którym znajduje się plik do importu:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/2ukk0hti/crawler-data-store.jpg" alt="Crawler data store" /&gt;&lt;/p&gt;

&lt;p&gt;W kroku wyboru roli IAM wybieramy istnięjącą lub tworzymy nową rolę, która będzie umożliwi dostęp &lt;strong&gt;crawlerowi&lt;/strong&gt; do importowanego pliku:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/ktep0zsi/crawler-iam.jpg" alt="IAM role" /&gt;&lt;/p&gt;

&lt;p&gt;W kroku harmonogramu definiujemy jak często &lt;strong&gt;crawler&lt;/strong&gt; ma być uruchamiany. W przykładzie wybieramy opcję uruchamiania na żądanie:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/4pnmdiyn/crawler-schedule.jpg" alt="Schedule" /&gt;&lt;/p&gt;

&lt;p&gt;W kroku output wybieramy lub tworzymy bazę danych &lt;strong&gt;AWS Glue Data Catalog&lt;/strong&gt; w której będą przechowywane odkryte przez &lt;strong&gt;crawlera&lt;/strong&gt; metadane:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/235jqddj/crawler-output.jpg" alt="Output" /&gt;&lt;/p&gt;

&lt;p&gt;W ostatnim kroku możemy sprawdzić wprowadzone dane i zakończyć tworzenie &lt;strong&gt;crawlera&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/n3wb5wl3/crawler-review.jpg" alt="Review" /&gt;&lt;/p&gt;

&lt;p&gt;Po utworzeniu &lt;strong&gt;crawlera&lt;/strong&gt; możemy go uruchomić guzikiem &lt;strong&gt;Run crawler&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Wynikiem działania &lt;strong&gt;crawlera&lt;/strong&gt; jest tabela utworzona w bazie &lt;strong&gt;AWS Glue Data Catalog&lt;/strong&gt;, którą można podejrzeć w sekcji &lt;em&gt;Databases-&gt;Tables&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/gobdvgrd/data-catalog-tables.jpg" alt="data catalog tables" /&gt;&lt;/p&gt;

&lt;p&gt;Klikając w nazwę tabeli możemy podejrzeć wykryte metadane w niej zapisane:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/semlqlks/data-catalog-table-metadata.jpg" alt="data catalog table metadata" /&gt;&lt;/p&gt;

&lt;p&gt;Oraz wykryty schemat pliku do importu:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/q3so0kcf/data-catalog-table-schema.jpg" alt="data catalog table schema" /&gt;&lt;/p&gt;

&lt;h3&gt;3. Utworzenie joba AWS Glue&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; ma teraz schemat danych, które chcemy zaimportować.
Następnym krokiem jest zdefiniowanie zadania (&lt;strong&gt;AWS Glue job&lt;/strong&gt;) importu tych danych do bazy danych &lt;strong&gt;Postgres&lt;/strong&gt;.
&lt;strong&gt;AWS Glue job&lt;/strong&gt; jest skryptem wykonywalnym przez &lt;em&gt;Spark&lt;/em&gt;, który &lt;strong&gt;AWS Glue&lt;/strong&gt; pomaga nam wygenerować.&lt;/p&gt;

&lt;p&gt;Aby &lt;strong&gt;AWS Glue job&lt;/strong&gt; mógł zostać wykonany to muszą zaotać spełnione pewne warunki:
* &lt;strong&gt;VPC&lt;/strong&gt; w którym znajduje się baza danych &lt;strong&gt;Postgres&lt;/strong&gt; musi mieć możliwość komunikacji z &lt;strong&gt;S3 Bucket&lt;/strong&gt;.
* &lt;strong&gt;AWS Glue job&lt;/strong&gt; musi posiadać dostęp do &lt;strong&gt;VPC&lt;/strong&gt; w którym znajduje się baza danych &lt;strong&gt;Postgres&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;Utworzenie VPC Endpoint dla S3&lt;/h4&gt;

&lt;p&gt;Aby &lt;strong&gt;VPC&lt;/strong&gt; w którym znajduje się baza danych &lt;strong&gt;Postgres&lt;/strong&gt; miała możliwość komunikacji z &lt;strong&gt;S3 Bucket&lt;/strong&gt;, należy utworzyć &lt;strong&gt;VPC Endpoint&lt;/strong&gt; dla &lt;strong&gt;S3&lt;/strong&gt;.
&lt;strong&gt;VPC Endpoint&lt;/strong&gt; dla &lt;strong&gt;S3&lt;/strong&gt; umożliwia &lt;strong&gt;AWS Glue&lt;/strong&gt; korzystanie z prywatnych adresów &lt;em&gt;IP&lt;/em&gt; w celu uzyskania dostępu do &lt;strong&gt;S3&lt;/strong&gt; bez dostępu do publicznego &lt;em&gt;Internetu&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Aby skonfigurować dostęp do &lt;strong&gt;S3&lt;/strong&gt; w widoku &lt;strong&gt;VPC&lt;/strong&gt; wybieramy sekcję &lt;strong&gt;Endpoints&lt;/strong&gt; i naciskamy guzik &lt;strong&gt;Create Endpoint&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;W sekcji &lt;em&gt;Service category&lt;/em&gt; wybieramy wartość &lt;em&gt;AWS services&lt;/em&gt; i w sekcji &lt;em&gt;Service name&lt;/em&gt; wybieramy wartość &lt;em&gt;com.amazonaws.eu-central-1.s3&lt;/em&gt; z typem &lt;em&gt;Gateway&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/szybridd/endpoint-service.jpg" alt="endpoint service" /&gt;&lt;/p&gt;

&lt;p&gt;W sekcji &lt;em&gt;VPC&lt;/em&gt; wybieramy identyfikator naszego &lt;strong&gt;VPC&lt;/strong&gt; i zaznaczamy tablicę routingu dla tego &lt;strong&gt;VPC&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/mhwpl034/endpoint-vpc.jpg" alt="endpoint vpc" /&gt;&lt;/p&gt;

&lt;p&gt;W sekcji &lt;em&gt;Policy&lt;/em&gt; zostawiamy wartość &lt;em&gt;Full Access&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/tpjl2uck/endpoint-policy.jpg" alt="endpoint policy" /&gt;&lt;/p&gt;

&lt;h4&gt;Ustawienie dostępu AWS Glue JDBC Data Store do VPC z bazą Postgres&lt;/h4&gt;

&lt;p&gt;Aby umożliwić komunikację komponentów &lt;strong&gt;AWS Glue&lt;/strong&gt; należy skonfigurować dla nich dostęp do bazy &lt;strong&gt;Amazon RDS&lt;/strong&gt;. Aby to umożliwić należy stworzyć grupę zabezpieczeń z samoodnoszącą się regułą przychodzącą dla wszystkich portów TCP.&lt;/p&gt;

&lt;p&gt;Grupę zabezpieczeń dla bazy &lt;strong&gt;Postgres&lt;/strong&gt; konfigurujemy w widoku &lt;strong&gt;Amazon RDS -&gt; Databases&lt;/strong&gt; wybierając instancję naszej bazy &lt;strong&gt;Postgres&lt;/strong&gt; i przechodząc do sekcji &lt;strong&gt;Security Groups&lt;/strong&gt; w jej detalach. W sekcji &lt;strong&gt;Security Groups&lt;/strong&gt; wybieramy grupę zabezpieczeń dla której chcemy mieć dostęp z &lt;strong&gt;AWS Glue&lt;/strong&gt; i przechodzimy do jej detali w konsoli &lt;strong&gt;Amazon EC2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;W zakładce &lt;strong&gt;Inbound rules&lt;/strong&gt; dodajemy nową samoodnoszącą się regułę wybierając typ &lt;em&gt;All TCP&lt;/em&gt; i &lt;em&gt;Custom Source&lt;/em&gt; z identyfikatorem tej grupy zabezpieczeń jako wartość.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/213bgpuk/security-group-rule.jpg" alt="SG rule" /&gt;&lt;/p&gt;

&lt;h4&gt;Dodanie połączenia do bazy Postgres&lt;/h4&gt;

&lt;p&gt;Połączenie do bazy danych dodajemy w widoku &lt;strong&gt;AWS Glue&lt;/strong&gt; w sekcji &lt;strong&gt;Databases -&gt; Connections&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;W pierwszym kroku nadajemy nazwę połączenia i definiujemy jego typ oraz silnik bazy danych:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/w15eai0q/connection-properties.jpg" alt="connection" /&gt;&lt;/p&gt;

&lt;p&gt;W następnym kroku definiujemy dane połączenia do bazy danych:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/01jbueml/connection-access.jpg" alt="connection access" /&gt;&lt;/p&gt;

&lt;p&gt;W ostatnim kroku sprawdzamy poprawność wprowadzonych danych i kończymy dodawanie połączenia:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/clejwbdl/connection-review.jpg" alt="connection review" /&gt;&lt;/p&gt;

&lt;h4&gt;Utworzenie definicji joba AWS Glue&lt;/h4&gt;

&lt;p&gt;Tworzenie definicji odbywa się w widoku &lt;strong&gt;AWS Glue&lt;/strong&gt; w sekcji &lt;strong&gt;Jobs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;W pierwszym kroku nadajemy nazwę zadania i wybieramy rolę &lt;strong&gt;IAM&lt;/strong&gt; która ma uprawnienia do używanych przez zadanie zasobów. Definiujemy również typ zadania, wersję &lt;strong&gt;Glue&lt;/strong&gt; i skrypt który będzie używany w zadaniu &lt;strong&gt;AWS Glue&lt;/strong&gt;, dane te są domyślnie wypełnione w taki sposób, że &lt;strong&gt;AWS Glue&lt;/strong&gt; wygeneruje skrypt zadania za nas i zapisze go w specjalnie utworzonym buckecie &lt;strong&gt;S3&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/pgqhznhm/job-definition.jpg" alt="job definition" /&gt;&lt;/p&gt;

&lt;p&gt;W drugim kroku wybieramy tabelę ze schematem danych do zaimportowania z &lt;strong&gt;AWS Glue Data Catalog&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/4zsisf1t/job-data-source.jpg" alt="job data source" /&gt;&lt;/p&gt;

&lt;p&gt;W następnym kroku wybieramy rodzaj transformacji danych:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/ibhf1uay/job-transform.jpg" alt="transform" /&gt;&lt;/p&gt;

&lt;p&gt;W następnym kroku wybieramy połączenie do docelowej bazy danych &lt;strong&gt;Postgres&lt;/strong&gt;, które utworzyliśmy wcześniej:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/1xse4tbv/job-target.jpg" alt="target" /&gt;&lt;/p&gt;

&lt;p&gt;W ostatnim kroku definiujemy mapowanie danych z pliku do kolumn w bazie danych:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/ehpbhtgv/job-schema.jpg" alt="schema" /&gt;&lt;/p&gt;

&lt;p&gt;Po naciśnięciu guzika &lt;strong&gt;Save job and edit script&lt;/strong&gt; wygenerowany zostaje skrypt zadania:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/iuubniiq/job-script.jpg" alt="script" /&gt;&lt;/p&gt;

&lt;p&gt;Zadanie możemy uruchomić klikając guzik &lt;strong&gt;Run job&lt;/strong&gt;.
Zaznaczając nazwę zadania na liście zadań &lt;strong&gt;AWS Glue jobs&lt;/strong&gt; możemy podejrzeć historię jego uruchomień:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/bxbhxyqc/job-history.jpg" alt="history" /&gt;&lt;/p&gt;

&lt;p&gt;Wyniki działania zadania podejrzeć możemy używając zapytania SQL i ulubionego klienta &lt;strong&gt;Postgres&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://smsoft.pl/media/5peeh5qr/job-result.jpg" alt="job result" /&gt;&lt;/p&gt;

&lt;h2&gt;Plusy i minusy AWS Glue&lt;/h2&gt;

&lt;h3&gt;Plusy:&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; jest usługą bezserwerową, więc nie musisz zarządzać zasobami.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; jest łatwy w użyciu i szybki w konfiguracji.&lt;/li&gt;
&lt;li&gt;Nie musisz pisać kodu, ale możesz!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; integruje się z różnymi usługami AWS jako źródłowe lub docelowe punkty końcowe.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AWS Glue&lt;/strong&gt; jest dobry we wnioskowaniu schematów danych.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Minusy:&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Nie można kontrolować zasobów obliczeniowych używanych przez &lt;strong&gt;AWS Glue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pod maską &lt;strong&gt;Glue&lt;/strong&gt; działa &lt;em&gt;Apache Spark&lt;/em&gt; i akceptuje tylko skrypty &lt;em&gt;Python&lt;/em&gt; lub &lt;em&gt;Scala&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Zadania &lt;strong&gt;AWS Glue&lt;/strong&gt; mają zimny czas startu.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Cena AWS Glue&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Joby&lt;/strong&gt; i &lt;strong&gt;crawlery&lt;/strong&gt; &lt;strong&gt;AWS Glue&lt;/strong&gt; są rozliczane według „godziny DPU”, co odpowiada godzinie pracy przy użyciu 4 procesorów wirtualnych i 16 GB pamięci. Koszt 1 DPU (0,44 USD/godz.). Chociaż jednostki DPU są wyceniane godzinowo, rozliczane są co sekundę, z minimum jedną minutą.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS Glue Catalog&lt;/strong&gt; jest wyceniany według liczby skatalogowanych obiektów i liczby żądań do katalogu (pierwszy milion obiektów i żądań miesięcznie jest bezpłatny).&lt;/p&gt;</description>
      <pubDate>Fri, 08 Oct 2021 08:05:32 +0200</pubDate>
      <a10:updated>2021-10-08T08:05:32+02:00</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1134</guid>
      <link>http://smsoft.pl/blog/v-bezpieczenstwo-aplikacji-asp-net-mvc/</link>
      <category>ASP.NET MVC</category>
      <title>V. Bezpieczeństwo aplikacji ASP.NET MVC</title>
      <description>&lt;div&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Ponieważ w dzisiejszych czasach coraz więcej transakcji jest wykonywanych za pośrednictwem internetu to programiści &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; muszą zadbać o to aby dane użytkowników ich aplikacji pozostały bezpieczne.&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Konfiguracja uwierzytelnienia&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Serwer &lt;strong&gt;IIS&lt;/strong&gt; od wersji 7 jest podstawowym mechanizmem uwierzytelnienia ponieważ został wyposażony w siedmiu dostawców uwierzytelnienia. Są oni podzieleni na dwa różne podejścia: &lt;strong&gt;challenge-based&lt;/strong&gt; i &lt;strong&gt;login redirection–based authentication&lt;/strong&gt;. Pierwsze z nich polega na tym, że użytkownik musi zgłosić się do serwera po uwierzytelnienie. Drugie ma miejsce wtedy gdy klient wysyła dane uwierzytelniające do aplikacji i aplikacja na ich podstawie wie gdzie ma przekierować użytkownika. Domyślnie zainstalowany jest tylko dostawca uwierzytelnienia anonimowego (ang. &lt;em&gt;Anonymous authentication provider&lt;/em&gt;).&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Dostawcy uwierzytelnienia&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Wybór mechanizmu uwierzytelnienia zależy od kilku czynników. Pierwszym z nich jest miejsce gdzie są przechowywane dane użytkownika które będą używane do sprawdzenia tożsamości użytkownika. Jeżeli używasz uwierzytelnienia opartego o &lt;strong&gt;Active Directory&lt;/strong&gt; to powinieneś wybrać jedną ze standardowych metod &lt;strong&gt;challenge-based&lt;/strong&gt;. Jeżeli używasz innej technologii to musisz użyć nadpisanego lub niestandardowego dostawcy. Jeżeli nie używasz żadnego dostawcy to prawdopodobnie uwierzytelnienie typu &lt;strong&gt;Forms&lt;/strong&gt; będzie odpowiednie.&lt;/p&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Anonymous authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie &lt;strong&gt;anonimowe&lt;/strong&gt; nie wymaga aby użytkownik podał jakiekolwiek dane uwierzytelniające ale w czasie konfiguracji trzeba wybrać konto użytkownika lub serwis który będzie wykorzystywany do dostępu do plików. Można to konto wybrać dla każdej strony lub puli aplikacji. Jeżeli wybrany użytkownik nie ma wystarczających uprawnień do zasobu to serwer zwróci &lt;strong&gt;Unauthorized&lt;/strong&gt;. Użycie właściwości &lt;strong&gt;User&lt;/strong&gt; z uwierzytelnieniem &lt;strong&gt;Anonymous&lt;/strong&gt; spowoduje zwrócenie pustego ciągu znaków. Uwierzytelnienie &lt;strong&gt;Anonymous&lt;/strong&gt; na serwerze &lt;strong&gt;IIS&lt;/strong&gt; można ustawić za pomocą konfiguracji lub za pomocą komendy:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;appcmd set config -section:anonymousAuthentication -enabled:true
&lt;/pre&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Basic authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie &lt;strong&gt;podstawowe&lt;/strong&gt; (ang. &lt;em&gt;Basic credentials&lt;/em&gt;) wymaga poświadczeń sprawdzanych przez domenę które są zakodowane używając &lt;strong&gt;Base64&lt;/strong&gt; ale wysyłane informacje nie są wysyłane bezpiecznym kanałem. Uwierzytelnienie podstawowe jest nakładką na tradycyjnych zabezpieczenia systemu Windows więc użytkownik musi posiadać albo konto na serwerze lub w &lt;strong&gt;Active Directory&lt;/strong&gt;. Uwierzytelnienie podstawowe na serwerze &lt;strong&gt;IIS&lt;/strong&gt; można ustawić za pomocą konfiguracji lub za pomocą komendy:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;appcmd set config -section:basicAuthentication -enabled:true
&lt;/pre&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Digest authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie &lt;strong&gt;szyfrowane&lt;/strong&gt; (ang. &lt;em&gt;Digest authentication&lt;/em&gt;) jest podobne do uwierzytelnienia podstawowego z tym wyjątkiem, że jest przesyłane zaszyfrowane. Proces upewniania się przez serwer (ang. &lt;em&gt;challenge-response process&lt;/em&gt;), że dane są wysyłane zaszyfrowaną drogą składa się z następujących kroków:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Serwer wysyła wyzwanie do klienta w odpowiedzi na żądanie strony zabezpieczonej.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient generuje unikalną wartość dla wyzwania.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient tworzy skrót wyzwania i wartości wyzwania.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient zwraca wartość wyzwania i skrót do serwera.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Serwer tworzy własną wersję skrótu aby upewnić się, że jest identyczna z tym który otrzymał od serwera.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Serwer tworzy nowy skrót wyzwania i wartości wyzwania po czym wysyła je do klienta.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient tworzy własną wersję skrótu aby sprawdzić poprawność otrzymanych danych.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Forms authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie &lt;strong&gt;formularzy&lt;/strong&gt; (ang &lt;em&gt;Forms authentication&lt;/em&gt;) jest jednym z najczęściej używanych mechanizmów ponieważ pozwala na uwierzytelnienie użytkownika w dowolny sposób bez użycia systemu zabezpieczeń systemu &lt;em&gt;Windows&lt;/em&gt;. konfigurując uwierzytelnienie formularzy tworzymy własną stronę logowania na której podajemy dane uwierzytelniające użytkownika które służą do porównania z danymi zapisanymi na serwerze, zwykle w bazie danych. Po udanym zalogowaniu, wezwanie do dostawcy członkostwa (&lt;strong&gt;Membership provider&lt;/strong&gt;) zapewnia, że tokenu uwierzytelniania użytkownika jest ustawiony i że użytkownik może pozostać zalogowany przez resztę sesji. Jeżeli dane są potwierdzone przez system uwierzytelnienia to używamy metody &lt;strong&gt;FormsAuthentication.SetAuthCookie&lt;/strong&gt; ustawiającej ciasteczko dla sesji użytkownika. Przykład kodu wysyłającego ciasteczko uwierzytelniające:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[ControllerAction]
public void Authenticate(string uname, string pass)
{
    User user = dbContext.Users.First (x=&amp;gt;x.UserName.Equals(uname();

    if (user != null &amp;amp;&amp;amp; user.Password.Equals(EncryptHash(pass))
    {
        FormsAuthentication.SetAuthCookie(uname, false);
        RedirectToAction("Main", "DashBoard");
    }
    // unable to login
    RenderView("Index", new LoginViewData
    {
        ErrorMessage = "Invalid credentials."
    });
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jeżeli uwierzytelnienie się powiedzie to obiekt &lt;strong&gt;User&lt;/strong&gt; jest wstawiany do &lt;strong&gt;HttpContext&lt;/strong&gt; tak jak we wszystkich innych typach uwierzytelnienia. Można również dodać ten obiekt do obiektu wątku. Jeżeli chcemy wyczyścić ciasteczko uwierzytelnienia to możemy użyć metody &lt;strong&gt;FormsAuthentication.ClearAuthCookie&lt;/strong&gt;.&lt;/p&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Windows authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie &lt;strong&gt;Windows&lt;/strong&gt; używa danych użytkownika zalogowanego do systemu &lt;em&gt;Windows&lt;/em&gt; i przesyła je w żądaniach &lt;em&gt;HTTP&lt;/em&gt;. Istnieją dwa protokoły uwierzytelnienia &lt;em&gt;Windows&lt;/em&gt;: &lt;strong&gt;NTLM&lt;/strong&gt; i &lt;strong&gt;Kerberos&lt;/strong&gt;. Protokoły te są wspierane tylko przez przeglądarki firmy &lt;em&gt;Microsoft&lt;/em&gt;.&lt;/p&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;ASP.NET Impersonation authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jest to dodatek do uwierzytelnienia &lt;strong&gt;Windows&lt;/strong&gt;, które pozwala aplikacjom &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; tożsamości &lt;em&gt;Windows&lt;/em&gt; w bardziej dynamiczny sposób. Dzięki temu dodatkowi można użyć tożsamości &lt;em&gt;Windows&lt;/em&gt; aby otrzymać dostęp do zasobów takich jak sieć i pliki. Ustawienie w &lt;strong&gt;Web.config&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;configuration&amp;gt;
    &amp;lt;system.web&amp;gt;
        &amp;lt;identity impersonate="true" /&amp;gt;
    &amp;lt;/system.web&amp;gt;
&amp;lt;/configuration&amp;gt;
&lt;/pre&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Client Certificate authentication and IIS Client Certificate authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnianie &lt;strong&gt;certyfikatu klienta&lt;/strong&gt; (ang. &lt;em&gt;Client Certificate authentication&lt;/em&gt;) dopasowuje certyfikat pomiędzy użytkownikiem i serwerem i używa tego dopasowania do uwierzytelnienia. Uwierzytelnienie certyfikatu klienta na serwerze &lt;strong&gt;IIS&lt;/strong&gt; pozwala na sprawdzenie danych w &lt;strong&gt;Active Directory&lt;/strong&gt; oraz na lokalnym serwerze. Jest to najbardziej skomplikowany mechanizm uwierzytelnienia i wymaga certyfikatu &lt;strong&gt;SSL&lt;/strong&gt; zainstalowanego na serwerze i dla każdego klienta.&lt;/p&gt;
&lt;h4 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.2em;"&gt;Custom authentication&lt;/h4&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kiedy żadne z rozwiązań nie pasuje do naszej aplikacji możemy zmodyfikować mechanizm uwierzytelnienia. Najlepszym sposobem jest implementacja interfejsów &lt;strong&gt;System.Security.Principal.IIdentity&lt;/strong&gt; i &lt;strong&gt;System.Security.Principal.IPrincipal&lt;/strong&gt;. &lt;strong&gt;IPrincipal&lt;/strong&gt; zawiera informacje o użytkowniku i jego rolach. &lt;strong&gt;IIdentity&lt;/strong&gt; zawiera informacje o użytkownikach, czy są uwierzytelnieni i imiona. Są to dwa domyślne interfejsy woków uwirzytelnienia i autoryzacji w &lt;strong&gt;.NET&lt;/strong&gt;. Jeżeli posiadamy własną implementację tych interfejsów to możemy ją powiązać z &lt;strong&gt;HttpContext&lt;/strong&gt; i aktualnym wątkiem co pozwala na użycie atrybutu &lt;strong&gt;Authorize&lt;/strong&gt; bez konieczności przerabiania kodu. Kilka domyślnych implementacji tych interfejsów przychodzi z &lt;strong&gt;.NET&lt;/strong&gt;: &lt;strong&gt;WindowsIdentity and WindowsPrincipal&lt;/strong&gt;, &lt;strong&gt;FormsIdentity and GenericPrincipal&lt;/strong&gt; oraz &lt;strong&gt;GenericIdentity and GenericPrincipal&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład implementacji interfejsów:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class CustomPrincipal : IPrincipal
{
    public CustomPrincipal(CustomIdentity identity)
    {
        this.Identity = identity;
    }    

    public IIdentity Identity { get; private set; }

    public bool IsInRole(string role)
    {
        return true;
    }
}

public class CustomIdentity : IIdentity
{
    public CustomIdentity(string name)
    {
        this.Name = name;
    }

    public string AuthenticationType
    {
        get { return "Custom"; }
    }

    public bool IsAuthenticated
    {
        get { return !string.IsNullOrEmpty(this.Name); }
    }

    public string Name { get; private set; }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uzycie &lt;strong&gt;IIdentity&lt;/strong&gt; i &lt;strong&gt;IPrincipal&lt;/strong&gt; pozwala na wstawienie własnych obiektów do właściwości aktualnego wątku &lt;strong&gt;currentPrinciple&lt;/strong&gt; oraz do właściwości &lt;strong&gt;User&lt;/strong&gt; w &lt;strong&gt;HttpContext&lt;/strong&gt;. W czasie przetwarzania żądania moduł &lt;strong&gt;HttpModule&lt;/strong&gt; analizuje i sprawdza informacje o użytkowniku oraz dodaje te dane do &lt;strong&gt;HttpContext&lt;/strong&gt; aby były dostępne dla reszty obsługi żądania. Te informację są również dodawane do wątku poprzez &lt;strong&gt;System.Threading.Thread.CurrentPrincipal&lt;/strong&gt;. Pomimo, że&lt;strong&gt;HttpContext&lt;/strong&gt; jest dostępny dla obiektu &lt;strong&gt;HttpHandler&lt;/strong&gt;, to &lt;strong&gt;HttpContext&lt;/strong&gt; nie jest zwykle czymś do czego można dostać się poza projektem MVC.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Ustawienie &lt;strong&gt;CurrentPrincipal&lt;/strong&gt; z &lt;strong&gt;HttpContext&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;// Make sure the principals are in sync
System.Threading.Thread.CurrentPrincipal = System.Web.HttpContext.Current.User;
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Egzekwowanie ustawień uwierzytelniania&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Głównym sposobem wykonania uwierzytelnianie w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; jest użycie atrybutów dziedziczących z klasy &lt;strong&gt;AuthorizeAttribute&lt;/strong&gt;. jest to filtr który może być używany z akcjami, kontrolerami lub globalnie. Atrybut &lt;strong&gt;Authorize&lt;/strong&gt; mówi systemowi, że każdy użytkownik wywołujący akcję kontrolera musi być uwierzytelniony. Atrybut &lt;strong&gt;AllowAnonymous&lt;/strong&gt; jest atrybutem, który mówi systemowi, że użytkownik wywołujący akcję kontrolera nie musi być uwierzytelniony. Czasem może wystąpić sytuacja kiedy nie chcemy używać atrybutów wymuszających aby użytkownik był uwierzytelniony ale za to jeżeli jest to chcemy mięć dostęp do tych danych. W takich sytuacjach można w kodzie użyć właściwości &lt;strong&gt;Thread.CurrentPrincipal.Identity.IsAuthenticated&lt;/strong&gt; oraz &lt;strong&gt;HttpContext.Current.User.Identity.IsAuthenticated&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład dodania globalnego filtru:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    filters.Add(new HandleErrorAttribute());
    filters.Add(new AuthorizeAttribute());
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Dla wszystkich dostawców można użyć tego samego kodu aby dowiedzieć się czy użytkownik jest uwierzytelniony. Wyjątkiem jest dostawca uwierzytelnienia anonimowego, dla którego atrybut &lt;strong&gt;Authorize&lt;/strong&gt; blokuje dostęp. Ponieważ uwierzytelnienie formularzy pozwala na niestandardowe rozwiązania to również w jego przypadku autoryzacja może być obsługiwana inaczej niż dla innych dostawców. Domyślnie w aplikacjach &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; uwierzytelnienie formularzy używa tokenu do przechowywania informacji pomiędzy żądaniami. ten token może być zapisany jako ciasteczko lub jako część zapytania &lt;em&gt;query string&lt;/em&gt;. Token powinien być zabezpieczony, najlepiej używając &lt;strong&gt;HTTPS&lt;/strong&gt; dla całej komunikacji. Filtr &lt;strong&gt;RequireHttpsAttribute&lt;/strong&gt; może być dodany na poziomie akcji, kontrolera lub globalnie.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład dodania filtru &lt;strong&gt;RequireHttpsAttribute&lt;/strong&gt; do pliku &lt;strong&gt;Global.asax&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    filters.Add(new HandleErrorAttribute());
    filters.Add(new AuthorizeAttribute());
    filters.Add(new RequireHttpsAttribute());
}
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Użycie ciasteczek do zarządzania sesją użytkownika&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aplikacja MVC jest zaimplementowana w sposób bezstanowy, co oznacza, że aplikacja wie tylko tyle ile zostało jej powiedziane w żądaniu. Czasami istnieje potrzeba zachowania stanu użytkownika i poprzednich żądań. Do tego typu zadań bardzo przydatną funkcją jest sesja. &lt;strong&gt;Forms authentication&lt;/strong&gt; używa ciasteczek do zarządzania tzw biletem uwierzytelnienia, który jest zaszyfrowaną wersją nazwy użytkownika przechowywanej w ciasteczku. to ciasteczko jest kontenerem HTTP który nie może być odczytany ani manipulowany po stronie klienta. Przykład kodu tworzącego obiekt &lt;strong&gt;FormsAuthenticationTicket&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
    1,
    userName,
    DateTime.Now,
    DateTime.Now.AddDays(90),
    createPersistentCookie, // a Boolean indicating whether a cookie
                            // should be created on the user's machine
    String.Join(";",rolesArr) //user's roles
);

// add cookie to response stream
string encTicket = FormsAuthentication.Encrypt(authTicket);

System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.
    FormsCookieName, encTicket);
System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Do obiektu &lt;strong&gt;FormsAuthenticationTicket&lt;/strong&gt; możemy dostać się poprzez właściwość &lt;strong&gt;Ticket&lt;/strong&gt; klasy &lt;strong&gt;FormIdentity&lt;/strong&gt;. Klasa &lt;strong&gt;FormIdentity&lt;/strong&gt; jest implementacją &lt;strong&gt;UserIdentity&lt;/strong&gt; i można ją odczytać z klasy &lt;strong&gt;HttpContext&lt;/strong&gt; lub z wątku. W powyższym przykładzie we właściwości &lt;strong&gt;UserData&lt;/strong&gt; przechowane zostały role użytkownika ale można tam zapisać dowolną wartość. Właściwość &lt;strong&gt;Ticket&lt;/strong&gt; można odszyfrować za pomocą metody &lt;strong&gt;FormsAuthentication.Encrypt&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Alternatywą dla ciasteczek jest przechowywanie danych sesji po stronie serwera. W takim wypadku z każdym żądaniem wysyłany jest identyfikator sesji klienta &lt;strong&gt;SessionId&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Konfiguracja dostawców członkostwa&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Dostawcy członkostwa (ang. &lt;em&gt;Membership providers&lt;/em&gt;) byli częścią &lt;strong&gt;ASP.NET&lt;/strong&gt; od &lt;strong&gt;.NET 2.0&lt;/strong&gt;. W pracy z klasycznym modelem konfiguracja i instalacja były wprowadzane za pomocą konfiguracji w pliku &lt;strong&gt;Web.config&lt;/strong&gt;. Przykład konfiguracji dla &lt;strong&gt;SqlMembershipProvider&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;system.web&amp;gt;
    &amp;lt;membership&amp;gt;
        &amp;lt;providers&amp;gt;
        &amp;lt;clear/&amp;gt;
        &amp;lt;add name="AspNetSqlMembershipProvider" connectionStringName="sampleDB" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="2" passwordAttemptWindow="15" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral /&amp;gt;
        &amp;lt;/providers&amp;gt;
    &amp;lt;/membership&amp;gt;
&amp;lt;/system.web&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Od czasu utworzenia frameworka, pewne aspekty członkostwa uległy zmianie. Przykładowo dla &lt;strong&gt;OAuth&lt;/strong&gt; i &lt;strong&gt;OpenID&lt;/strong&gt; użytkownik nie ma przypisanego hasła. W &lt;strong&gt;ASP.NET MVC 4&lt;/strong&gt; wprowadziło koncept &lt;strong&gt;SimpleMembership&lt;/strong&gt; i &lt;strong&gt;SimpleRoles&lt;/strong&gt;. Pozwala to na dostosowanie dostępu do magazynu danych poprzez określenie tabeli, klucza identyfikującego oraz nazwy użytkownika w czasie inicjalizacji. Metody &lt;strong&gt;SimpleMembership&lt;/strong&gt; są zaimplementowane jako dostawcy implementujący rdzeń API ASP.NET. &lt;strong&gt;SimpleRoleProvider&lt;/strong&gt; implementuje klasę bazową &lt;strong&gt;RoleProvider&lt;/strong&gt;. &lt;strong&gt;SimpleMembershipProvider&lt;/strong&gt; zostało wprowadzone do zarządzania interakcji z bazą danych. Dodano również klasę &lt;strong&gt;WebSecurity&lt;/strong&gt;, która posiada wiele pomocniczych metod biznesowych. Domyślni dostawcy członkostwa którzy są częścią &lt;strong&gt;ASP.NET&lt;/strong&gt; posiadają możliwość przechowywania informacji jako par klucz - wartość w specjalnej tabeli w bazie danych. &lt;strong&gt;SimpleMembership&lt;/strong&gt; pozwala na użycie jakiejkolwiek tabeli zawierającej unikalne wartości nazwy użytkownika i identyfikatora. &lt;strong&gt;SimpleMembershipProvider&lt;/strong&gt; wymaga dodatkowych tabel do przechowywania ról i informacji takich jak np hasło. Poniższy kod prezentuje jak utworzyć tabele. Trzeba zainicjować klasę &lt;strong&gt;WebSecurity&lt;/strong&gt; przy uruchomieniu poprzez wywołanie metody &lt;strong&gt;InitializeDatabaseConnection&lt;/strong&gt;.&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;WebSecurity.InitializeDatabaseConnection(string connectionString, string providerName,
    string userTableName, string userIdColumn, string userNameColumn, bool autoCreateTables)
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Klasa &lt;strong&gt;WebSecurity&lt;/strong&gt; jest użyteczną nakładką na &lt;strong&gt;SimpleMembership&lt;/strong&gt;. Zawiera metody &lt;strong&gt;Login&lt;/strong&gt;, &lt;strong&gt;ResetPassword&lt;/strong&gt;, &lt;strong&gt;CreateAccount&lt;/strong&gt;, i &lt;strong&gt;ChangePassword&lt;/strong&gt;. Pomimo tego, że &lt;strong&gt;ASP.NET MVC 4&lt;/strong&gt; posiada tylko &lt;strong&gt;SimpleMembershipProvider&lt;/strong&gt;, to można napisać własnego dostawcę. Dostawcy są zwykle konfigurowani w pliku konfiguracyjnym. W przypadku &lt;strong&gt;SimpleMembership&lt;/strong&gt; jest to zwykle &lt;strong&gt;connection string&lt;/strong&gt;. Przykład konfiguracji:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;connectionStrings&amp;gt;
    &amp;lt;add name="DefaultConnection" connectionString="ConnectionStringHere" providerName="System.Data.SqlClient" /&amp;gt;
&amp;lt;/connectionStrings&amp;gt;
&amp;lt;appSettings&amp;gt;
    &amp;lt;add key="TableName" value="CustomLoginTable"/&amp;gt;
    &amp;lt;add key="IdColumn" value="Id"/&amp;gt;
    &amp;lt;add key="UsernameColumn" value="Username"/&amp;gt;
&amp;lt;/appSettings&amp;gt;
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Custom membership providers&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Niestandardowy dostawca członkostwa może być utworzony poprzez dziedziczenie z klasy &lt;strong&gt;AuthorizeAttribute&lt;/strong&gt; lub dziedziczenie z dostawcy uwierzytelnienia &lt;strong&gt;Forms&lt;/strong&gt; i nadpisanie odpowiednich metod. Aby nadpisać klasę &lt;strong&gt;FormsAuthentication&lt;/strong&gt; należy zwrócić uwagę na dwa aspekty autoryzacji które obracają się wokół biletu. Pierwszym jest klasa &lt;strong&gt;FormsAuthentication&lt;/strong&gt;, która ustawia ciasteczko; drugim jest &lt;strong&gt;FormsAuthenticationModule&lt;/strong&gt; wykonujący pracę z każdym żądaniem. Klasa &lt;strong&gt;FormsAuthentication&lt;/strong&gt; posiada metodę &lt;strong&gt;SetAuthCookie&lt;/strong&gt; przypisującą bilet do ciasteczka. Szyfrowanie jest wykonywane używając elementu konfiguracji serwera. W przypadku farmy serwerów trzeba się upewnić, że wszystkie serwery maja ten sam klucz. moduł HTTP &lt;strong&gt;FormsAuthenticationModule&lt;/strong&gt; wyszukuje ciasteczko i bilet. Jeżeli odszyfrowanie sie nie powiedzie to użytkownik jest traktowany jako nieuwierzytelniony. Więcej o &lt;a href="http://www.iis.net/learn/troubleshoot/security-issues/troubleshooting-forms-authentication"&gt;FormsAuthenticationModule&lt;/a&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Implementacja niestandardowego dostawcy wymaga dziedziczenia z klasy bazowej &lt;strong&gt;System.Web.Security.MembershipProvider&lt;/strong&gt;, która dziedziczy z &lt;strong&gt;ProviderBase&lt;/strong&gt;. Używając tego rozwiązania trzeba mieć na uwadze, że klasa &lt;strong&gt;WebSecurity&lt;/strong&gt; nie będzie działać ponieważ wymaga zaimplementowania &lt;strong&gt;ExtendedMembershipProvider&lt;/strong&gt;. Proces budowy niestandardowego dostawcy wymaga zaimplementowania 25 metod i właściwości, są to:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ApplicationName&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ChangePassword&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ChangePasswordQuestionAndAnswer&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;CreateUser&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;DeleteUser&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Description&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;EnablePasswordReset&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;EnablePasswordRetrieval&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;FindUsersByEmail&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;FindUsersByName&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetAllUsers&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetNumberOfUsersOnline&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetPassword&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetUser&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetUserNameByEmail&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Initialize&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;MaxInvalidPasswordAttempts&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Name&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;PasswordAttemptWindow&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;PasswordFormat&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;RequiresQuestionAndAnswer&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;RequiresUniqueEmail&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ResetPassword&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;UnlockUser&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;UpdateUser&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ValidateUser&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Więcej o tworzeniu niestandardowego dostawcy można przeczytać na stronie &lt;a href="https://msdn.microsoft.com/en-us/library/f1kyba5e%28v=vs.100%29.aspx"&gt;Implementing a Membership Provider&lt;/a&gt;.&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Konfiguracja autoryzacji&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Autoryzacja jest procesem nadawania użytkownikowi uprawnień do wykonania akcji na określonym zasobie. Najlepszym sposobem określenia uprawnień są role ponieważ są bardziej długotrwałe niż użytkownicy systemu. Tworząc role lepiej jest tworzyć je w oparciu o przywileje a nie stanowisko pracy np lepiej użyć &lt;em&gt;CanEditOrder&lt;/em&gt; niż &lt;em&gt;OrderPicker&lt;/em&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Tworzenie ról&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;System członkostwa &lt;strong&gt;ASP.NET&lt;/strong&gt; opiera się na modelu dostawcy, który działa jako framework służący dla programistów w celu zwiększenia lub zmiany funkcjonalności wokół uwierzytelniania i zarządzania użytkownikami. Domyślnie &lt;strong&gt;ASP.NET&lt;/strong&gt; posiada kilku dostawców członkostwa którzy posiadają standardowe implementacje uwierzytelnienia i autoryzacji. Ci dostawcy posiadają powiązanych dostawców ról jak np &lt;strong&gt;SqlRoleProvider&lt;/strong&gt; współpracujący z &lt;strong&gt;SqlMembershipProvider&lt;/strong&gt;. Jeżeli aplikacja używa autoryzacji opartej o system Windows jak np &lt;strong&gt;Active Directory&lt;/strong&gt; to zarządzanie rolami jest częścią systemu. Uwierzytelnienie &lt;strong&gt;Forms&lt;/strong&gt; używa innego zestawu tabel do zarządzania rolami. Można użyć narzędzia konfiguracji stron &lt;strong&gt;ASP.NET&lt;/strong&gt; używając uwierzytelnienia &lt;strong&gt;Forms&lt;/strong&gt; z dostawcą członkostwa np &lt;strong&gt;SimpleMembership&lt;/strong&gt;. Ponieważ &lt;strong&gt;ASP.NET&lt;/strong&gt; nie posiada szablonu do tworzenia ról to aby dodać role trzeba stworzyć odpowiedni interfejs użytkownika i wywołać &lt;strong&gt;Roles API&lt;/strong&gt;. Uruchamiając nową aplikację możemy dodać odpowiednie role poprzez wykonanie odpowiedniego skryptu w bazie danych. Jeżeli chcemy wspierać role tworzone przez użytkowników to musimy napisać tę funkcjonalność samemu.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Autoryzacja ról poprzez konfigurację&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W pliku &lt;strong&gt;Web.config&lt;/strong&gt; można zarządzać autoryzacją. przykład konfiguracji dla &lt;strong&gt;SQL membership role provider&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;roleManager defaultProvider="AdminRoleProvider" enabled="true" cacheRolesInCookie="true"&amp;gt;
    &amp;lt;providers&amp;gt;
    &amp;lt;clear/&amp;gt;
    &amp;lt;add name="SqlProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="DefaultConnection" applicationName="MyApplication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
        passwordAttemptWindow/&amp;gt;
    &amp;lt;/providers&amp;gt;
&amp;lt;/roleManager&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Używając &lt;strong&gt;SimpleMembershipProvider&lt;/strong&gt; z &lt;strong&gt;SimpleRole&lt;/strong&gt; zamiast pliku konfiguracyjnego używa się kodu:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public static void InitializeDatabaseConnection(string connectionStringName, string
    userTableName, string userIdColumn, string userNameColumn, bool autoCreateTables)
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Autoryzacja ról programowo&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;ASP NET MVC&lt;/strong&gt; oferuje kilka dróg do utworzenia ról programowo. Przypisane role można sprawdzić na kilka sposobów: poprzez atrybut kontrolera lub akcji &lt;strong&gt;[Authorize(Roles=”Admin”)]&lt;/strong&gt;, lub w kodzie używając metody &lt;strong&gt;IsUserInRole&lt;/strong&gt; lub &lt;strong&gt;GetRolesForUser&lt;/strong&gt;. W kodzie można również odnieść się do ról użytkownika za pomocą metod takich jak &lt;strong&gt;RoleProvider.GetRolesForUser&lt;/strong&gt;, &lt;strong&gt;HttpContext.User.IsInRole&lt;/strong&gt; i &lt;strong&gt;RoleProvider.IsUserInRole&lt;/strong&gt;. Role w atrybucie mogą być wymienione po przecinku, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[Authorize(Roles="Administrator,CanEditOrder")]
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład sprawdzania ról w kodzie:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;string[] userRolesArray = Roles.GetRolesForUser();
string[] rolesForContentArray = DbContext.GetRolesForViewFromDb(thisViewName);
if (userRolesArray.Intersect(RolesForContentArray).Count &amp;gt; 0)
{
    // The user is authorized
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład użycia &lt;strong&gt;WebSecurity&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;WebSecurity.RequireRoles("Admin", "OtherRole");
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Własny dostawca ról&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Własnego dostawcę ról można utworzyć implementując &lt;strong&gt;System.Web.Security.RoleProvider&lt;/strong&gt;. Pozwala to dostosować role do naszych potrzeb w sytuacjach kiedy standardowi dostawcy ról nie spełniają naszych wymagań. Lista wymaganych właściwości i metod do zaimplementowania:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;AddUsersToRoles&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ApplicationName&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;CreateRole&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;DeleteRole&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Description&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;FindUsersInRole&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetAllRoles&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetRolesForUser&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;GetUsersInRole&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Initialize&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;IsUserInRole&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Name&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;RemoveUsersFromRoles&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;RoleExists&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Więcej można przeczytać na stronie &lt;a href="https://technet.microsoft.com/en-us/subscriptions/8fw7xh74%28v=vs.100%29.aspx"&gt;Implementing a Role Provider&lt;/a&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Implementcaja autoryzacji serwisów WCF&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kiedy aplikacja jest klientem serwisu &lt;strong&gt;WCF&lt;/strong&gt; to bardzo często trzeba zarządzać autoryzacją pomiędzy aplikacją a serwisem. To zarządzania uprawnieniami można użyć kolekcji &lt;strong&gt;Credentials&lt;/strong&gt; przy tworzeniu pośrednika połączenia z serwisem (komenda &lt;strong&gt;Add Service Reference&lt;/strong&gt; w &lt;strong&gt;VS&lt;/strong&gt;). Można stworzyć poświadczenie używając nazwy użytkownika i hasła, określonych poświadczeń &lt;strong&gt;Windows&lt;/strong&gt; lub &lt;strong&gt;WindowsIdentity&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład przekazania poświadczeń używając pośrednika serwisu w kodzie serwera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;WCFServiceCient client = new WCFServiceCient();
client.ClientCredentials.UserName.UserName = "Apps User Name";
client.ClientCredentials.UserName.Password = "Apps Password";
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład przekazania poświadczeń Windows:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;NetworkCredential credentials = new NetworkCredential();
credentials.Domain = "windows domain";
credentials.UserName = " Apps User Name";
credentials.Password = " Apps Password";

WCFServiceCient client = new WCFServiceCient();
client.ClientCredentials.Windows.ClientCredential = credentials;
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Claims-based authentication&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie federacyjne pozwala aplikacji polegać na innej aplikacji w kwestii uwierzytelnienia (dostawca tożsamości jak &lt;strong&gt;Windows Azure&lt;/strong&gt; lub &lt;strong&gt;Facebook&lt;/strong&gt;). Kiedy dostawca uwierzytelni użytkownika to przesyła token do aplikacji który zawiera poświadczenia (ang. &lt;strong&gt;claims&lt;/strong&gt;). Poświadczenia są porcjami informacji, które dostawca udostępnia aplikacji, np imię czy adres email. Uwierzytelnienie federacyjne jest przykładem uwierzytelnienia opartego o poświadczenia i jest używane do autoryzacji tak jak tradycyjny system oparty na rolach, ale może być o wiele bardziej ziarnisty. Używa po prostu innego podejścia do autoryzacji; zamiast autoryzowania dostępu w zależności od roli używa listy innych własności otrzymanych od zaufanego dostawcy.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Windows Azure Active Directory Access Control&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;Windows Azure Access Control Service (ACS)&lt;/strong&gt; pozwala na zaimplementowanie uwierzytelnienia federacyjnego (ang. &lt;em&gt;federated authentication&lt;/em&gt;). &lt;strong&gt;ACS&lt;/strong&gt; pozwala na pracę z innymi standardowymi dostawcami tożsamości jak &lt;strong&gt;Windows Live ID&lt;/strong&gt; i &lt;strong&gt;Facebook&lt;/strong&gt;. Czterej podstawowi uczestnicy procesu uwierzytelniania &lt;strong&gt;ACS&lt;/strong&gt; to strona ufająca (aplikacja), przeglądarka klienta, dostawca tożsamości i &lt;strong&gt;ACS&lt;/strong&gt;. Ważne cechy &lt;strong&gt;ACS&lt;/strong&gt; to:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Integracja z &lt;strong&gt;Windows Identity Foundation (WIF)&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wsparcie dla znanych dostawców tożsamości jak &lt;strong&gt;Facebook&lt;/strong&gt;, &lt;strong&gt;Microsoft&lt;/strong&gt; , &lt;strong&gt;Yahoo&lt;/strong&gt; i &lt;strong&gt;Google&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wsparcie dla &lt;strong&gt;Active Directory Federation Services (ADFS) 2.0&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wsparcie dla protokołów &lt;strong&gt;OAuth 2.0&lt;/strong&gt; , &lt;strong&gt;WS-Trust&lt;/strong&gt; i &lt;strong&gt;WS-Federation&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wsparcie dla różnych formatów tokenów, a w tym &lt;strong&gt;JSON Web Token (JWT)&lt;/strong&gt;, &lt;strong&gt;Security Assertion Markup Language (SAML) 1.1&lt;/strong&gt;, &lt;strong&gt;SAML 2.0&lt;/strong&gt; i &lt;strong&gt;Simple Web Token (SWT)&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Portal web do zarządzania.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kroki autoryzacji użytkownika przez &lt;strong&gt;ACS&lt;/strong&gt;:&lt;/p&gt;
&lt;ol style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient wysyła żądanie do aplikacji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Ponieważ żądanie nie jest uwierzytelnione to aplikacja odsyła użytkownika do &lt;strong&gt;ACS&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ACS&lt;/strong&gt; przekierowuje żądanie do dostawcy tożsamości, którego może wybrać aplikacja lub użytkownik. Dostawca udostępnia stronę uwierzytelnienia.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient loguje się na tej stronie. Dostawca zatwierdza autoryzację i przesyła token do klienta.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Klient przekazuje token do &lt;strong&gt;ACS&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ACS&lt;/strong&gt; sprawdza token i tworzy nowy token który zawiera poświadczenia i wysyła klienta z tokenem do aplikacji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Aplikacja sprawdza token i poświadczenia. Po zatwierdzeniu odsyła odpowiedź na żądanie z kroku 1.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Uwierzytelnienie &lt;strong&gt;ACS&lt;/strong&gt; może wydawać się skomplikowane ale przestrzeń nazw &lt;strong&gt;Microsoft.Web.WebPages.OAuth&lt;/strong&gt; abstrachuje większość pracy przekształcając procedurę w dwie metody &lt;strong&gt;VerifyAuthentication&lt;/strong&gt; i &lt;strong&gt;Login&lt;/strong&gt;. &lt;strong&gt;OAuthWebSecurity.VerifyAuthentication&lt;/strong&gt; jest głównym procesem używanym do tworzenia zwrotnego zewnętrznego uwierzytelniania. Po otrzymaniu uwierzytelnienia można zapisać ciasteczko, które pozwoli określić w kolejnych żądaniach czy użytkownik jest nadal uwierzytelniony. Kod pokazujący logowanie zewnętrzne z użyciem &lt;strong&gt;ACS&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public ActionResult ExternalLoginCallback(string returnUrl)
{
    // send the request for a login to the ACS
    AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(
        Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
    if (!result.IsSuccessful)
    {
        return RedirectToAction("ExternalLoginFailure");
    }
    // check for the access token
    if (result.ExtraData.Keys.Contains("accesstoken"))
    {
        Session["accesstoken "] = result.ExtraData["accesstoken"];
    }
    // login to the local application using information from provider
    if (OAuthWebSecurity.Login(
        result.Provider,
        result.ProviderUserId,
        createPersistentCookie: false))
    {
        return RedirectToLocal(returnUrl);
    }
    if (User.Identity.IsAuthenticated)
    {
        // If the current user is logged in add the new account
        OAuthWebSecurity.CreateOrUpdateAccount(
            result.Provider,
            result.ProviderUserId,
            User.Identity.Name);
        return RedirectToLocal(returnUrl);
    }
    else
    {
        // User is new, ask for their desired membership name
        string loginData = OAuthWebSecurity.SerializeProviderUserId(
            result.Provider,
            result.ProviderUserId);
        ViewBag.ProviderDisplayName =
            OAuthWebSecurity.GetOAuthClientData(result.Provider).DisplayName;
        ViewBag.ReturnUrl = returnUrl;
        return View("ExternalLoginConfirmation", new RegisterExternalLoginModel
        {
            UserName = result.UserName,
            ExternalLoginData = loginData,
            FullName = result.ExtraData["name"],
            Link = result.ExtraData["link"]
        });
    }
}
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Tworzenie niestandardowych tokenów używając WIF&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;WIF (Windows Identity Foundation)&lt;/strong&gt; jest częścią &lt;strong&gt;.NET Framework&lt;/strong&gt; i może być używane do budowania aplikacji rozpoznających tożsamość. Można użyć go do zarządzania którykolwiek z wbudowanych mechanizmów obsługi tokenów, jak również do obsługi tokenów które przenoszą informacje. &lt;strong&gt;WIF&lt;/strong&gt; abstrahuje protokoły &lt;strong&gt;WS-Trust&lt;/strong&gt; i &lt;strong&gt;WS-Federation&lt;/strong&gt; pozwalając programiście na użycie API przy budowaniu systemów obsługujących poświadczenia. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; wspiera wykorzystanie uwierzytelniania prowadzonego przez federacje co jest krytyczne aby użyć scenariusza &lt;strong&gt;single sign-on&lt;/strong&gt; lub przekazać ciężar i odpowiedzialność uwierzytelniania do innej aplikacji. &lt;strong&gt;WS-Trust&lt;/strong&gt; jest specyfikacją &lt;strong&gt;WS-*&lt;/strong&gt; i standardem &lt;strong&gt;OASIS&lt;/strong&gt;, który dostarcza rozszerzenia do &lt;strong&gt;WS-Security&lt;/strong&gt;; zajmującym się z wydawaniem, odnowienia i walidacją tokenów zabezpieczeń. &lt;strong&gt;WS-Federation&lt;/strong&gt; jest rozszerzeniem &lt;strong&gt;WS-Trust&lt;/strong&gt;, które zapewnia architekturę dla zapewnienia oddzielania między formatami tokenów, protokół do pobrania tych tokenów i zaufany mechanizm do zarządzania nimi wszystkimi. &lt;strong&gt;WS-Federation&lt;/strong&gt; udostępnia model usług, który dostarcza informacji o tożsamości i tokenów dla wszelkiego rodzaju usług internetowych i aplikacji, z mnóstwem możliwych relacji zaufania. &lt;strong&gt;WS-Federation&lt;/strong&gt; może być stosowany bezpośrednio przez klienta, ponieważ zarządza i określa syntaktyczny związek między klientem a serwerem. Jego jedynym celem jest umożliwienie wspólnego procesu dostępu do operacji tożsamości zarówno dla klientów i serwisów internetowych. Usługa tokenu zabezpieczeń (&lt;strong&gt;STS - security token service&lt;/strong&gt;) jest składnikiem usługi, która buduje, podpisuje i zarządza tokenami protokołów &lt;strong&gt;WS-Trust&lt;/strong&gt; i &lt;strong&gt;WS-Federation&lt;/strong&gt;. &lt;strong&gt;WIF&lt;/strong&gt; wykonuje całą pracę za programistę. &lt;strong&gt;Windows Azure ACS&lt;/strong&gt; jest przykładem często używanego &lt;strong&gt;STS&lt;/strong&gt;. Z wprowadzeniem &lt;strong&gt;WIF&lt;/strong&gt;, poświadczenia zostały dodane klas bazujących na klasie &lt;strong&gt;System.Security.Claims.ClaimsPrincipal&lt;/strong&gt;. Dzięki temu każda z klas ma dostęp do poświadczeń i programiści mogą użyć interfejsów &lt;strong&gt;IIdentity&lt;/strong&gt; i &lt;strong&gt;IPrincipal&lt;/strong&gt; do pracy z informacjami o tożsamości. Pomimo, że &lt;strong&gt;.NET Framework&lt;/strong&gt; wspiera wiele typów tokenów to czasami trzeba użyć innych typów tokenów. Na szczęście nie trzeba zastępować istniejącego mechanizmu transferu (&lt;strong&gt;WS-Federation&lt;/strong&gt;), tylko obsłużyć nowy typ tokenu. Definicja niestandardowego tokenu dla &lt;strong&gt;WIF&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;m:MyCustomToken xmlns:m="urn:mycustomtoken" m:Id="SomeID" m:Issuer="urn:SomeIssuer" m:Audience="https://mywebsite/" m:ValidFrom="2013-01-01" m:ValidTo="2099-12-31"&amp;gt;
    &amp;lt;m:Claim Name="FirstName" Namespace="urn:firstname"&amp;gt;John&amp;lt;/m:Claim&amp;gt;
    &amp;lt;m:Claim Name="LastName" Namespace="urn:lastname"&amp;gt;Doe&amp;lt;/m:Claim&amp;gt;
    &amp;lt;m:Claim Name="Role" Namespace="urn:role"&amp;gt;Supervisor&amp;lt;/m:Claim&amp;gt;
    &amp;lt;Signature xmlns="http://www.w3.org/2000/09/xmldsig#"&amp;gt;
        &amp;lt;SignedInfo&amp;gt;
            &amp;lt;CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/
xml-exc-c14n#" /&amp;gt;
            &amp;lt;SignatureMethod Algorithm="http://www.w3.org/2000/09/
xmldsig#rsa-sha1" /&amp;gt;
            &amp;lt;Reference URI=""&amp;gt;
                &amp;lt;Transforms&amp;gt;
                    &amp;lt;Transform Algorithm="http://www.w3.org/2000/09/
xmldsig#enveloped-signature" /&amp;gt;
                    &amp;lt;Transform Algorithm="http://www.w3.org/2001/10/
xml-exc-c14n#" /&amp;gt;
                &amp;lt;/Transforms&amp;gt;
                &amp;lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /&amp;gt;
                &amp;lt;DigestValue&amp;gt;SomeDigestValueHere&amp;lt;/DigestValue&amp;gt;
            &amp;lt;/Reference&amp;gt;
        &amp;lt;/SignedInfo&amp;gt;
        &amp;lt;SignatureValue&amp;gt;… not shown …&amp;lt;/SignatureValue&amp;gt;
        &amp;lt;KeyInfo&amp;gt;
            &amp;lt;X509Data&amp;gt;
                &amp;lt;X509Certificate&amp;gt;… not shown …&amp;lt;/X509Certificate&amp;gt;
            &amp;lt;/X509Data&amp;gt;
        &amp;lt;/KeyInfo&amp;gt;
    &amp;lt;/Signature&amp;gt;
&amp;lt;/m:MyCustomToken&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Ten token musi być również zarządzany jako klasa dziedzicząca z &lt;strong&gt;SecurityToken&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class MyCustomToken : SecurityToken
{
    public List&amp;lt;Claim&amp;gt; Claims {get; set;}
    public XmlElemnt Signature {get; set;}
    public bool ValidateThisSignature()
    {
        // code to validate the signature
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Każdy token używany w systemie musi posiadać odpowiednią obsługę. Tworząc klasę obsługi tokenu trzeba dziedziczyć z &lt;strong&gt;SecurityTokenHandler&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public override ClaimsIdentityCollection ValidateToken(SecurityToken token)
{
    ClaimsIdentityCollection claimsIdentityCollection = new ClaimsIdentityCollection();
    if (token is MyCustomToken)
    {
        MyCustomToken mycustomtoken = token as MyCustomToken;
        if (mycustomtoken.ValidateThisSignature())
        {
            IClaimsIdentity newIdentity = new ClaimsIdentity((token as
                MyCustomToken).Claims);
        }
    }
    claimsIdentityCollection.Add(newIdentity);
    return claimsIdentityCollection;
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aby aplikacja mogła używać nowego tokenu należy ją skonfigurować jak poniżej:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;configSections&amp;gt;
    &amp;lt;!-- Registers the microsoft.IdentityModel configuration section --&amp;gt;
    &amp;lt;section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection,
Microsoft.IdentityModel, Version=3.5.0.0" /&amp;gt;
&amp;lt;/configSections&amp;gt;
&amp;lt;microsoft.identityModel&amp;gt;
    &amp;lt;service&amp;gt;
        &amp;lt;securityTokenHandlers&amp;gt;
            &amp;lt;remove type="Microsoft.IdentityModel.Tokens.WindowsUserNameSecurityTokenHandler,
Microsoft.IdentityModel" /&amp;gt;
            &amp;lt;add type="MyCustomToken.CustomUserNamePasswordValidatorSecurityTokenHandler,
MyCustomToken" /&amp;gt;
        &amp;lt;/securityTokenHandlers&amp;gt;
    &amp;lt;/service&amp;gt;
&amp;lt;/microsoft.identityModel&amp;gt;
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Obsługa tokenów SAML i SWT&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;SAML 2.0&lt;/strong&gt; jest protokołem opartym o &lt;strong&gt;XML&lt;/strong&gt;, który używa tokenu zawierającego twierdzenia lub pakiety informacji, aby przekazać informacje o zleceniodawcy (zwykle użytkowniku końcowym) pomiędzy &lt;strong&gt;SAML authority&lt;/strong&gt; lub &lt;strong&gt;identity provider&lt;/strong&gt; a &lt;strong&gt;service provider&lt;/strong&gt;. &lt;strong&gt;SAML 2.0&lt;/strong&gt; pozwala na webowe scenariusze uwierzytelnienia i autoryzacji a w tym &lt;strong&gt;single sign-on&lt;/strong&gt;, &lt;strong&gt;federated identity&lt;/strong&gt; i &lt;strong&gt;web services security&lt;/strong&gt;. Ponieważ tokeny &lt;strong&gt;SAML&lt;/strong&gt; są podpisywane kluczem asymetrycznym to użytkownik nie może tworzyć własnych tokenów. Tokeny &lt;strong&gt;SAML&lt;/strong&gt; mogą również być szyfrowane. Token &lt;strong&gt;Simple Web Token (SWT)&lt;/strong&gt; jest prostszym obiektem podpisywanym kluczem symetrycznym. &lt;strong&gt;JWT&lt;/strong&gt; reprezentuje poświadczenia które mają zostać przetransferowane przez dwie strony. Poświadczenia w &lt;strong&gt;JWT&lt;/strong&gt; są kodowane w formacie obiektu &lt;strong&gt;JSON&lt;/strong&gt;, który jest podpisany cyfrowo używając &lt;strong&gt;JSON Web Signature (JWS)&lt;/strong&gt; i mogą być szyfrowane używając &lt;strong&gt;JSON Web Encryption (JWE)&lt;/strong&gt;. &lt;strong&gt;JWT&lt;/strong&gt; nie jest jeszcze skończony ale posiada duże wsparcie i ma zastąpić w przyszłości &lt;strong&gt;SWT&lt;/strong&gt;. &lt;strong&gt;WIF&lt;/strong&gt; opiera się na klasach obsługi tokenów, które tworzą, odczytują, zapisują i sprawdzają tokeny. Klasy obsługi tokenów są punktem rozszerzalności &lt;strong&gt;WIF&lt;/strong&gt;. &lt;strong&gt;WIF&lt;/strong&gt; posiada kilka wbudowanych klas obsługi tokenów, które mogą być nadpisane w razie potrzeby, należą do nich:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;EncryptedSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;KerberosSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;MembershipUserNameSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;RsaSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Saml2SecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;SamlSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;SessionSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;UserNameSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;WindowsUserNameSecurityTokenHandler&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;X509SecurityTokenHandler&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Klasa &lt;strong&gt;Saml2SecurityTokenHandler&lt;/strong&gt; obsługuje serializację i deserializację &lt;strong&gt;SAML 2.0 Assertions-backed tokens&lt;/strong&gt; do obiektu &lt;strong&gt;Saml2SecurityToken&lt;/strong&gt;. Można ustawić &lt;strong&gt;STS&lt;/strong&gt; który obsłuży token &lt;strong&gt;SAML 2.0&lt;/strong&gt; poprzez dodanie instancji &lt;strong&gt;Saml2SecurityTokenHandler&lt;/strong&gt; do kolekcji &lt;strong&gt;SecurityTokenHandlerCollection&lt;/strong&gt;. Dokonuje się tego zwykle w konfiguracji:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;system.webServer&amp;gt;
    &amp;lt;modules&amp;gt;
        &amp;lt;add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule,
Microsoft.IdentityModel" preCondition="managedHandler" /&amp;gt;
    &amp;lt;/modules&amp;gt;
&amp;lt;/system.webServer&amp;gt;
&amp;lt;configuration&amp;gt;
    &amp;lt;configSections&amp;gt;
        &amp;lt;section name="microsoft.identityModel" type="Microsoft.IdentityModel.Web.Configuration.
MicrosoftIdentityModelSection, Microsoft.IdentityModel" /&amp;gt;
    &amp;lt;/configSections&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;microsoft.identityModel&amp;gt;
    &amp;lt;service&amp;gt;
        &amp;lt;securityTokenHandlers&amp;gt;
            &amp;lt;securityTokenHandlerConfiguration&amp;gt;
                &amp;lt;clear/&amp;gt;
                &amp;lt;add type="Microsoft.IdentityModel.Tokens.Saml11.
Saml11SecurityTokenHandler, Microsoft.IdentityModel"&amp;gt;
                    &amp;lt;samlSecurityTokenRequirement issuerCertificateValidationMode="PeerOrChainTrust" issuerCertificateRevocationMode="Online" issuerCertificateTrustedStoreLocation="LocalMachine" mapToWindows="false" useWindowsTokenService="false"&amp;gt;
                        &amp;lt;nameClaimType value="http://schemas.xmlsoap.org/ws/2005/05/
identity/claims/name" /&amp;gt;
                        &amp;lt;roleClaimType value="schemas.microsoft.com/ws/2006/04/
identity/claims/role" /&amp;gt;
                    &amp;lt;/samlSecurityTokenRequirement&amp;gt;
                &amp;lt;/add&amp;gt;
            &amp;lt;/securityTokenHandlerConfiguration&amp;gt;
        &amp;lt;/securityTokenHandlers&amp;gt;
    &amp;lt;/service&amp;gt;
&amp;lt;/microsoft.identityModel&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Niektóre typy tokenów nie mają wbudowanej obsługi dostarczonej z &lt;strong&gt;WIF&lt;/strong&gt;. Można dodać implementację niestandardowych tokenów wykonując następujące kroki:&lt;/p&gt;
&lt;ol style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Należy użyć klasy &lt;strong&gt;SecurityTokenHandler&lt;/strong&gt; jako klasy bazowej.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Należy nadpisać następujące metody:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;CanReadToken&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ReadToken&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;CanWriteToken&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;WriteToken&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;CanValidateToken&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;ValidateToken&lt;/li&gt;
&lt;/ul&gt;
&lt;ol style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;W konfiguracji należy dodać referencje do nowej klasy w sekcji . Poniżej przykład dla klasy &lt;strong&gt;SWTTokenHandler&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;system.identityModel&amp;gt;
    &amp;lt;identityConfiguration saveBootstrapContext=”true”&amp;gt;
        &amp;lt;securityTokenHandlers&amp;gt;
            &amp;lt;add type=”SWTToken.SWTTokenHandler, SWTToken” /&amp;gt;
        &amp;lt;/securityTokenHandlers&amp;gt;
    &amp;lt;/identityConfiguration&amp;gt;
&amp;lt;/system.identityModel&amp;gt;
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Zarządzanie integralnością danych&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Zarządzanie prywatnością, poczuciem bezpieczeństwa i integralnością danych ma kluczowe znaczenie dla bezpieczeństwa. Większość aplikacji &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; składa się z wprowadzania, wykonywania pracy na a następnie wyprowadzanie danych.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Terminologia związana z szyfrowaniem&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Szyfrowanie jest procesem zamiany zwykłego tekstu na nieczytelny format (ang. &lt;strong&gt;ciphertext&lt;/strong&gt;) który może zostać odszyfrowany tylko przez aplikacje które posiadają klucz odszyfrowujący.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Funkcja skrótu tworzy wartość w oparciu o ciągi danych w zbiorze danych. Zwracana wartość jest ciągiem o stałej długości i zawsze jest taka sama dla tego samego ciągu wejściowego. Po przesłaniu danych, wartość skrótu jest porównywana ze skrótem oryginalnych danych. Jeżeli są takie same to oznacza, że przesłane dane nie zostały zmienione. Funkcja skrótu jest często wykorzystywana do przechowywania haseł.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Secure Hash Algorithm (SHA)&lt;/strong&gt; jest obecnie najpopularniejszym algorytmem tworzącym skróty. Posiada on kilka podtypów min &lt;strong&gt;SHA-0&lt;/strong&gt; do &lt;strong&gt;SHA-3&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Solenie jest procesem dodawania losowego ciągu do danych wejściowych przed utworzeniem skrótu lub przed szyfrowaniem. Solenie utrudnia nieautoryzowany dostęp do danych poprzez dodanie nieprzewidywalności.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Algorytmy symetryczne i niesymetryczne są używane w procesie szyfrowania. Szyfrowanie symetryczne używa tego samego klucza do szyfrowania i odszyfrowania danych. Szyfrowanie asymetryczne używa dwóch różnych kluczy, które są komplementarne. Klucz publiczny jest szeroko rozpowszechniony i jest wykorzystywany do szyfrowania, natomiast klucz prywatny służy do odszyfrowania danych zaszyfrowanych kluczem publicznym.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Advanced Encryption Standard (AES)&lt;/strong&gt; jest najczęściej wykorzystywanym algorytmem szyfrowania symetrycznego.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Secure Sockets Layer (SSL)&lt;/strong&gt; jest przykładem protokołu używającego szyfrowania asymetrycznego. Serwer web posiada i zarządza kluczem szyfrującym prywatnym podczas gdy publikuje klucz publiczny do wszystkich przeglądarek które odpytują serwer. Pozwala to przeglądarkom zaszyfrować informacje zanim wyślą je do serwera.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Rivest, Shamir, and Adleman (RSA)&lt;/strong&gt; jest najpopularniejszym algorytmem szyfrowania asymetrycznego.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład szyfrowania strumienia algorytmem symetrycznym:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;using (RijndaelManaged rijndaelManaged = new RijndaelManaged())
{
    // assumes that the key and initialization vectors are already configured
    CryptoStream crypoStream = new CryptoStream(myManagedStream, rijndaelManaged.
        CreateEncryptor(),CryptoStreamMode.Write);
};
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład odszyfrowania strumienia zaszyfrowanego algorytmem symetrycznym:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;using (RijndaelManaged rijndaelManaged = new RijndaelManaged())
{
    // assumes that the key and initialization vectors are already configured
    CryptoStream crypoStream = new CryptoStream(myManagedStream, rijndaelManaged.
        CreateDecryptor(),CryptoStreamMode.Read);
};
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład szyfrowania algorytmem asymetrycznym:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
{
    RSA.ImportParameters(RSAKeyInfo);
    encryptedData = RSA.Encrypt(DataToEncrypt, DoOAEPPadding);
    decryptedData = RSA.Decrypt(encrypyedData, DoOAEPPadding);
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Parametr &lt;strong&gt;RSAKeyInfo&lt;/strong&gt; jest typu &lt;strong&gt;RSAParameters&lt;/strong&gt; i zawiera klucz publiczny.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Szyfrowanie sekcji konfiguracji aplikacji&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W &lt;strong&gt;.Net Framework&lt;/strong&gt; istnieją dwaj dostawcy szyfrowania konfiguracji: &lt;strong&gt;DPAPIProtectedConfigurationProvider&lt;/strong&gt; i &lt;strong&gt;RsaProtectedConfigurationProvider&lt;/strong&gt;. Drugi z nich pozwala na eksportowanie i importowanie klucza szłużącego do szyfrowania dzięki czemu pliki mogą być takie same na wielu serwerach. Za pomocą narzędzia &lt;strong&gt;aspnet_regiis.exe&lt;/strong&gt; z opcjami &lt;strong&gt;-pe&lt;/strong&gt;, &lt;strong&gt;-app&lt;/strong&gt; i &lt;strong&gt;-prov&lt;/strong&gt; można zaszyfrować sekcje pliku &lt;strong&gt;Web.config&lt;/strong&gt;. Służy to do ochrony pliku w przypadku gdy trafi on przypadkowo do użytkownika. Odszyfrowanie odbywa się za pomocą opcji &lt;strong&gt;-pd&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład szyfrowania sekcji:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;aspnet_regiis -pe "ConnectionStrings" -app "/MachineDPAPI" -prov
"RsaProtectedConfigurationProvider"
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Opcja &lt;strong&gt;-pe&lt;/strong&gt; wskazuje sekcję która ma zostać zaszyfrowana. Opcja &lt;strong&gt;-app&lt;/strong&gt; wskazuje wirtualną ścieżkę do aplikacji. Opcja &lt;strong&gt;-prov&lt;/strong&gt; wskazuje wybranego dostawcę szyfrowania.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kiedy chcemy użyć zaszyfrowanego pliku to musimy do konfiguracji załączyć klucz &lt;strong&gt;machineKey&lt;/strong&gt;, który został użyty do szyfrowania np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;machineKey validationKey="D61B3C89CB33A2F1422FF158AFF7320E8DB8CB5CDA1742572A487D94018787EF42682B20 2B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" decryptionKey="FBF50941F22D6A3B229EA593F24C41203DA6837F1122EF17" /&amp;gt;
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Podpisywanie danych aplikacji&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Podpisywanie danych aplikacji zapewnia uwierzytelnianie, autoryzację i niezaprzeczalność. Pozwala to na sprawdzenie partnera komunikacyjnego i daje potwierdzenie, że podpisane dane aplikacji przyszły od partnera, a nie kogoś innego. &lt;strong&gt;.Net Framework&lt;/strong&gt; zgrupował algorytmy szyfrowania i podpisu cyfrowego jako podklasy &lt;strong&gt;AsymmetricAlgorithm&lt;/strong&gt;. Klasa abstrakcyjna &lt;strong&gt;ystem.Security.Cryptography.DSA&lt;/strong&gt; definiuje metodę &lt;strong&gt;CreateSignature&lt;/strong&gt; akceptującą skrót &lt;strong&gt;SHA-1&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;// create the hash code of the text to sign
SHA1 sha = SHA1.Create();
byte[] hashcode = sha.ComputeHash(TextToConvert);

// use the CreateSignature method to sign the data
DSA dsa = DSA.Create();
byte[] signature = dsa.CreateSignature(hashcode);
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Podpis i skrót muszą być wysłane do metody weryfikującej &lt;strong&gt;VerifySignature&lt;/strong&gt; jako tablice bajtów, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;// create the hash code of the text to verify
SHA1 sha = SHA1.Create();
byte[] hashcode = sha.ComputeHash(TextToVerify);

// use the VerifySignature method to verify the DSA signature
DSA dsa = DSA.Create();
bool isSignatureValid = dsa.VerifySignature(hashcode, signature);
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Implementacja zabezpieczeń w ASP.NET&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Wiele aspektów &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; musi być zabezpieczone. Dotyczy to komunikacji pomiędzy klientem i serwerem jak również przechowywania prywatnych danych.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Certyfikat SSL&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;SSL&lt;/strong&gt; jest standardową technologią używaną do ustanowienia szyfrowanego połączenia pomiędzy przeglądarką a serwerem. &lt;strong&gt;SSL&lt;/strong&gt; używa &lt;strong&gt;PKI&lt;/strong&gt;, gdzie klucz publiczny jest związany z firmą lub za pośrednictwem strony trzeciej albo &lt;strong&gt;CA&lt;/strong&gt;. Przed użyciem &lt;strong&gt;SSL&lt;/strong&gt; trzeba włączyć wiązanie &lt;strong&gt;HTTPS&lt;/strong&gt; na serwerze. Później należy wysłać informacje identyfikacyjne wraz z &lt;strong&gt;Certificate Signing Request (CSR)&lt;/strong&gt; do &lt;strong&gt;CA&lt;/strong&gt; w celu sprawdzenia. Po potwierdzeniu informacji &lt;strong&gt;CA&lt;/strong&gt; przysyła dokument zawierający certyfikat który można załadować na serwer. Kiedy wiązanie &lt;strong&gt;HTTPS&lt;/strong&gt; jest dostępne to można użyć atrybutu &lt;strong&gt;RequireHttps&lt;/strong&gt; globalnie lub na poziomie kontrolerów i akcji aby były wykonywane tylko bezpiecznym połączeniem.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Solenie i haszowanie haseł&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przechowywanie haseł jako czysty tekst nie jest bezpieczne. Dwoma głównymi typami ataków na hasła są &lt;strong&gt;dictionary attack&lt;/strong&gt; i &lt;strong&gt;brute-force attack&lt;/strong&gt;. Najprostszą ochroną haseł jest solenie i tworzenie skrótu przed zapisaniem do bazy danych. Losowe ciągi służące do solenia można generować za pomocą &lt;strong&gt;Cryptographically Secure Pseudo-Random Number Generator (CSPRNG)&lt;/strong&gt;. Pozwala na to metoda &lt;strong&gt;RNGCryptoServiceProvider.GetBytes&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład użycia losowego ciągu przed soleniem i haszowaniem:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public static string CreateTheHash(string passwordToHash)
{
    // Generate the random salt
    RNGCryptoServiceProvider RNGcsp = new RNGCryptoServiceProvider();
    byte[] salt = new byte[NUMBER_OF_BYTES_FOR_THE_SALT];
    RNGcsp.GetBytes(salt);
    // Hash the password and encode the parameters
    byte[] hash = PBKDF2(passwordToHash, salt, PBKDF2_ITERATIONS, NUMBEROFBYTESINHASH);
    return PBKDF2_ITERATIONS + ":" + Convert.ToBase64String(salt) + ":" + Convert.ToBase64String(hash);
}

/// &amp;lt;summary&amp;gt;
/// Computes the PBKDF2-SHA1 hash of a password.
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name = "password"&amp;gt;The password to hash.&amp;lt;/param&amp;gt;
/// &amp;lt;param name = "salt"&amp;gt;The salt.&amp;lt;/param&amp;gt;
/// &amp;lt;param name = "iterations"&amp;gt;The PBKDF2 iteration count.&amp;lt;/param&amp;gt;
/// &amp;lt;param name = "outputBytes"&amp;gt;The length of the hash to generate, in bytes.&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;A hash of the password.&amp;lt;/returns&amp;gt;
private static byte[] PBKDF2(string password, byte[] salt, int iterations, int outputBytes)
{
    Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(password, salt);
    pbkdf2.IterationCount = iterations;
    return pbkdf2.GetBytes(outputBytes);
}

/// &amp;lt;summary&amp;gt;
/// Validates a password against the stored, hashed value.
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name = "password"&amp;gt;The password to check.&amp;lt;/param&amp;gt;
/// &amp;lt;param name = "goodHash"&amp;gt;A hash of the correct password.&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;True if the password is correct. False otherwise.&amp;lt;/returns&amp;gt;
public static bool ValidatePassword(string password, string goodHash)
{
    // Extract the parameters from the hash
    char[] delimiter =
    {
    ':'
    }

    ;
    string[] split = goodHash.Split(delimiter);
    int iterations = Int32.Parse(split[ITERATION_INDEX]);
    byte[] salt = Convert.FromBase64String(split[SALT_INDEX]);
    byte[] hash = Convert.FromBase64String(split[PBKDF2_INDEX]);
    byte[] testHash = PBKDF2(password, salt, iterations, hash.Length);
    return hash == testHash )
    ;
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Ponieważ użytkownik nie jest w stanie zobaczyć swojego starego hasła to należy użytkownikowi zapewnić możliwość zresetowania hasła. Proces ten musi również być zabezpieczony. Zwykle wykonuje się to za pomocą tzw pętli email. Pierw tworzy się losową wartość zapisaną w bazie danych i jest przypisana do jednego konta. Tę wartość wysyła się to użytkownika mailem z linkiem do resetowania hasła i limitem czasowym na wykorzystanie.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Użycie Html.Encode i biblioteki AntiXSS&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Atak &lt;strong&gt;JavaScript injection&lt;/strong&gt; polega na wstrzyknięciu przez hakera kodu &lt;strong&gt;JavaScript&lt;/strong&gt; do strony poprzez wstawienie kodu do adresu strony lub do formularza Przykładowo do formularza z komentarzem można by było wstawić skrypt:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;script src='http://imahacker.com/hackyou.js'&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jedną z technik zapobiegania jest kodowanie listy znaków. Pomocne są do tego helpery MVC:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;% Html.Encode(review.Title) %&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kodowanie danych można wykonać również przed ich wyświetlaniem:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public ActionResult Create(string message)
{
    var newEntry = new Entry();
    newEntry.Message = Server.HtmlEncode(message);
    newEntry.EntryDate = DateTime.Now;
    db.Entries.InsertOnSubmit(newEntry);
    db.SubmitChanges();
    return RedirectToAction("Index");
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Poza kodowaniem danych &lt;em&gt;Microsoft&lt;/em&gt; oferuje bibliotekę zbudowana specjalnie do ochrony przed tego typu atakami. Biblioteka &lt;strong&gt;AntiXSS&lt;/strong&gt; używa podejścia z akceptowalną listą znaków które zostaną kodowane przed wyświetleniem aby zapobiec atakom &lt;strong&gt;XSS&lt;/strong&gt;. Bibliotekę można pobrać jako pakiet &lt;strong&gt;NuGet&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Odroczona walidacja i obsługa żądań niezweryfikowanych&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Standardowym zachowaniem w &lt;strong&gt;ASP.NET 4.5&lt;/strong&gt; jest to, że wszystkie dane wysyłane z żądania klienta do serwera muszą przejść przez proces walidacji. Jednakże pozwala to również na odroczenie walidacji dopóki te dane nie są używane. Działanie to jest nazywane &lt;strong&gt;lazy request validation&lt;/strong&gt;, ponieważ minimalizuje pracę wykonywaną przez serwer w celu wykonania walidacji JIT. Jest to szczególnie użyteczne jeżeli mamy dane z wielu stron które wykonują wiele żądań do serwera. Można skonfigurować aplikację aby używała tej formy odroczonej walidacji poprzez ustawienie wartości atrybutu &lt;strong&gt;requestValidationMode&lt;/strong&gt; na “4.5” w sekcji &lt;strong&gt;httpRuntime&lt;/strong&gt; pliku &lt;strong&gt;Web.config&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;httpRuntime requestValidationMode="4.5" ... /&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Tak skonfigurowany system sprawdza poprawność tylko kiedy chcemy otrzymać dostęp do konkretnej wartości czyli &lt;em&gt;Request.Form[“description”]&lt;/em&gt; nie będzie powodowało sprawdzania wartości &lt;em&gt;equest.Form[“title”]&lt;/em&gt;. W starszych wersjach walidacja żądania była wykonywana na całej kolekcji. W &lt;strong&gt;ASP.NET 4.5&lt;/strong&gt; i &lt;strong&gt;ASP.NET MVC 4&lt;/strong&gt; programista ma dostęp do niesprawdzonych danych żądania. Właściwość &lt;strong&gt;Unvalidated&lt;/strong&gt; klasy &lt;strong&gt;HttpRequest&lt;/strong&gt; daje dostęp do wszystkich danych żądania, w tym &lt;strong&gt;Form&lt;/strong&gt;, &lt;strong&gt;Cookies&lt;/strong&gt; i &lt;strong&gt;QueryString&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;var s = context.Request.Unvalidated.Form["some_value"];
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Zapobieganie atakom SQL injection&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Atak &lt;strong&gt;SQL injection&lt;/strong&gt; występuje kiedy haker wstawi komendę &lt;strong&gt;SQL&lt;/strong&gt; do niezabezpieczonego zapytania. Przykład niezabezpieczonej komendy:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;con.Open();
SqlCommand com = new SqlCommand("Select * from Employee where EmpID =" +
    txtID.Text, con);
dr = com.ExecuteReader();
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jeżeli wartość &lt;em&gt;txtID&lt;/em&gt; jest wstawiana z formularza to w jej wartości można przekazać dodatkowe komendy &lt;strong&gt;SQL&lt;/strong&gt; przykładowo usuwające wszystkie rekordy w tabeli. Użycie średnika i komentarza na koncu komendy (—) powoduje, że &lt;strong&gt;SQL Server&lt;/strong&gt; wykona komendę, np: &lt;strong&gt;1;delete from Employee;—&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Ochronę przed tym rodzajem ataków zapewnia stosowanie parametryzacji zapytań używając &lt;strong&gt;SQLParameters&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;SqlDataAdapter adapter = new SqlDataAdapter("AuthorLogin", conn);
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter param = adapter.SelectCommand.Parameters.Add("@id",
    SqlDbType.VarChar, 11);
param.Value = submittedId;

// ...

SqlDataAdapter adapter = new SqlDataAdapter(
"SELECT username, email FROM user WHERE id = @id", conn);
SQLParameter param = adapter.SelectCommand.Parameters.Add("@id",
    SqlDbType.VarChar, 11);
paarm.Value = submittedId;
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Zapobieganie cross-site request forgeries (XSRFs)&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Ataki &lt;strong&gt;CSRF&lt;/strong&gt; wykorzystują uprawnienia ofiary do wykonania operacji w przeciwnym razie wymagającej jej zgody. Zabezpieczenie polega na użyciu metody &lt;strong&gt;AntiForgery&lt;/strong&gt; formularza i tokenu &lt;strong&gt;ValidateAntiForgeryToken&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[RequireSession]
[AcceptVerbs(HttpVerbs.Post)]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(string username, string password, string remember, string deviceToken, string apid)
{
}

// Sample of Razor View code
@using (Html.BeginForm("Login", "Authorize"))
{
    @Html.AntiForgeryToken();
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Daje to w rezultacie kod HTML postaci:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;form action="..." method="post"&amp;gt;
    &amp;lt;input name="__RequestVerificationToken" type="hidden" value="J58uHtyhGtyHgf8kkjgFDeRgjjKKk6khgCvb/ywruFIUUYYVHHHgfft87/gGsQUf/YuP" /&amp;gt;
    &amp;lt;!-- your form fields. --&amp;gt;
    &amp;lt;input type="submit" value="Submit"/&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/pre&gt;
&lt;div style="height: 0; width: 0; max-height: 0; max-width: 0; overflow: hidden; font-size: 0em; padding: 0; margin: 0;"&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Tue, 23 Aug 2016 14:59:24 Z</pubDate>
      <a10:updated>2016-08-23T14:59:24Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1133</guid>
      <link>http://smsoft.pl/blog/iv-rozwiazywanie-problemow-i-debugowanie-aplikacji-web/</link>
      <title>IV. Rozwiązywanie problemów i debugowanie aplikacji web</title>
      <description>&lt;div&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Rozwiązywanie problemów i debugowanie aplikacji jest normalnym procesem w czasie tworzenia i modyfikacji aplikacji. Na szczęście &lt;strong&gt;Visual Studio&lt;/strong&gt; posiada wiele narzędzi do śledzenia kodu w czasie uruchomienia aplikacji. Możliwość przechwycenia i zrozumienia błędów w środowisku produkcyjnym i programistycznym jest potężnym narzędziem, które pomaga upewnić się, że &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; poprawnie zarządza aplikacją.&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Zapobiegania i rozwiązywania problemów w czasie wykonywania&lt;/h2&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Performance Wizard&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Rozwiązywanie problemów z wydajnością ma kluczowe znaczenie dla tworzenia solidnych aplikacji. Narzędzie &lt;strong&gt;Performance Wizard&lt;/strong&gt; w &lt;strong&gt;Visual Studio&lt;/strong&gt; pozwala na skonfigurowanie profilowania aplikacji, które umożliwia przechwycenie informacji o użyciu CPU, pamięci i zasobach. Profiler wykonuje kompletne śledzenie wszystkich wywołań w aplikacji. Pozwala to śledzić logiczny przepływ w aplikacji. &lt;strong&gt;Performance Wizard&lt;/strong&gt; posiada kilka różnych metod monitorowania. Należą do nich: &lt;strong&gt;CPU sampling&lt;/strong&gt; (rekomendowana), &lt;strong&gt;Instrumentation&lt;/strong&gt;, &lt;strong&gt;.NET memory allocation (sampling)&lt;/strong&gt; i &lt;strong&gt;Resource contention data (concurrency)&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;CPU sampling&lt;/strong&gt; dostarcza informacji o pracy wykonywanej przez aplikację oraz jej wpływie na CPU. Próbkowanie jest lekkie i nie obciąża znacząco aplikacji. Polega na zbieraniu informacji co pewien okres cykli CPU. &lt;strong&gt;CPU sampling&lt;/strong&gt; jest bardziej jak sprawdzanie początkowe mówiące o tym gdzie powinniśmy zbadać naszą aplikację dokładniej.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Instrumentation&lt;/strong&gt; - instrumentacja jest bardziej inwazyjnym procesem. Narzędzie monitorujące dodaje kod do monitorowanych assembly (programista nie musi nic robić). ten kod pozwala zbadać dokładnie informacje w assembly, takie jak czasy wykonywania metod oraz wywoływaniawejściowe i wyjściowe w assembly. Monitorowane są również czasy spędzone na wykonywaniu poszczególnych metod w assembly niezależnie od zewnętrznych wywołań assembly. Taka analiza pozwala lepiej poznać problemy wydajnościowe.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;.NET memory allocation&lt;/strong&gt; jest sposobem na sprawdzenie problemów wydajnościowych zależnych od pamięci. Analiza obejmuje zarządzanie pamięciom aplikacji dla każdego obiektu w pamięci od momentu tworzenia do zbierania śmieci. Monitor może pracować w dwóch trybach. Pierwszy jest mniej inwazyjny i polega na próbkowaniu. Drugi korzysta z instrumentacji i daje dużo głębsze spojrzenie na pracę pamięci.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Resource contention data (concurrency)&lt;/strong&gt; jest to monitor wydajności użyteczny przy monitorowaniu aplikacji wielowątkowych. Monitor ten daje informacje o interakcjach pomiędzy wątkami i systemem, wykorzystaniem procesora, zajętości I/O i wiele innych użytecznych metryk.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Po wybraniu metody profilowania należy wybrać aplikację która ma być analizowana. Wy zakończeniu &lt;strong&gt;Performance Wizard&lt;/strong&gt; aplikacja zostaje uruchomiona i należy zacząć jej używać, szczególnie miejsca które chcemy zbadać. Po zamknięciu aplikacji zostanie wygenerowany raport. Poprzez wybór &lt;strong&gt;Analyze | Start Performance Analysis&lt;/strong&gt; można generować ten sam raport wielokrotnie.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Visual Studio Profiler&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;Visual Studio Profiler&lt;/strong&gt; wykonuje kompletne śledzenie wywołań występujących w aplikacji. Również używa próbkowania. Domyślne ustawienia dają w wyniku duży zestaw danych profilowania, które dostarczają informacji na temat mechanizmów działania aplikacji. Profiler wykrywa wszystkie wywołane metody i całą pamięć używaną do przetwarzania tych wywołań. Narzędzie zawiera szczegółowe informacje, takie jak ilość pamięci przeznaczonej dla różnych typów oraz ilość czasu spędzonego na tworzenie i usuwanie tych typów. Podczas gdy &lt;strong&gt;performance monitoring&lt;/strong&gt; skupia się na wydajności to profiler monitoruje całą aktywność i dokumentuje ją. Uruchomienie profilera odbywa się w oknie &lt;strong&gt;Analyze | Profiler&lt;/strong&gt;. Sekcja &lt;strong&gt;Hot Path&lt;/strong&gt; określa najdroższe ścieżki kodu aplikacji i podąża tymi ścieżkami, aż wykryje wyższy poziom przetwarzania przeprowadzanego (a nie delegowanego) przez jedną funkcję. Sekcja &lt;strong&gt;Functions Doing Most Individual Work&lt;/strong&gt; pomaga określić, gdzie dodatkowy czas może być wyeliminowany z wykonywania aplikacji, poprawiając tym samym wydajność aplikacji. Więcej informacji można znaleźć na stronie MSDN: &lt;a href="https://msdn.microsoft.com/en-us/library/ms182370.aspx"&gt;Configuring Performance Sessions&lt;/a&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Windows Performance Monitor&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Narzędzie systemu Windows &lt;strong&gt;Performance Monitor&lt;/strong&gt; pozwala śledzić wiele charakterystyk uruchomionych aplikacji. Posiada ono setki indywidualnych monitorów z których niektóre są przeznaczone do śledzenia &lt;strong&gt;ASP.NET&lt;/strong&gt;. Pojedyncze monitory są albo licznikami wydajności systemu albo licznikami wydajności aplikacji. Liczniki wydajności systemu są skupione na aplikacji i jej przebiegu uruchamiania, zatrzymywania i trwania. Liczniki wydajności aplikacji są skupione na detalach które dzieją się w aplikacji takich jak błędy, żądania i pamięć podręczna. Narzędzie to można uruchomić z menu &lt;strong&gt;RUN&lt;/strong&gt; wpisując &lt;strong&gt;perfmon&lt;/strong&gt;. Po uruchomieniu monitora można uruchomić &lt;strong&gt;Performance Monitor&lt;/strong&gt; klikając jego nazwę w lewym panelu. Pojawi się okno w którym za pomocą guzika plus można dodać liczniki.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Tracing, Logging i Debugging&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Śledzenie (ang. &lt;em&gt;tracing&lt;/em&gt;) jest funkcjonalnością pozwalającą na analizowanie aplikacji w czasie uruchomienia. Wyrażenia śledzące są dostępne w przestrzeni nazw &lt;strong&gt;System.Diagnostic&lt;/strong&gt; i pozwalają zapisywać informacje do jednej lub wielu klas nasłuchu &lt;strong&gt;TraceListener&lt;/strong&gt;. Zaimplementowane klasy nasłuchu to &lt;strong&gt; TextWriterTraceListener&lt;/strong&gt;, &lt;strong&gt;EventLogTraceListener&lt;/strong&gt;, &lt;strong&gt;DelimitedListTraceListener&lt;/strong&gt; i &lt;strong&gt;XmlWriterTraceListener&lt;/strong&gt;. Klasa nasłuchu może zapisywać informacje do pliku tekstowego lub innego formatu. Aby zapisać informacje z dowolnego miejsca w kodzie należy użyć obiektu klasy &lt;strong&gt;Trace&lt;/strong&gt; i jednej z metod &lt;strong&gt;Write&lt;/strong&gt;, &lt;strong&gt;WriteIf&lt;/strong&gt;, &lt;strong&gt;WriteLine&lt;/strong&gt; lub &lt;strong&gt;WriteLineIf&lt;/strong&gt;. Jeżeli istnieje taka potrzeba to można stworzyć własną klasę nasłuchu &lt;strong&gt;TraceListener&lt;/strong&gt;. Śledzenie można włączyć lub wyłączyć w każdej chwili. Aby uruchomić śledzenie należy wykonać kilka kroków konfiguracyjnych. Najpierw trzeba utworzyć co najmniej jedną klasę nasłuchu &lt;strong&gt;Systems.Diagnostics.TraceListeners&lt;/strong&gt;. Najprostszą metodą jest dodanie wpisu w pliku konfiguracyjnym:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;configuration&amp;gt;
    &amp;lt;system.diagnostics&amp;gt;
        &amp;lt;trace autoflush="false" indentsize="4"&amp;gt;
            &amp;lt;listeners&amp;gt;
                &amp;lt;add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TracingInfo.log" /&amp;gt;
                &amp;lt;remove name="Default" /&amp;gt;
            &amp;lt;/listeners&amp;gt;
        &amp;lt;/trace&amp;gt;
    &amp;lt;/system.diagnostics&amp;gt;
&amp;lt;/configuration&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład zapisu informacji do śledzenia:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;Trace.WriteLine(“Message”)
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Logowanie (ang. &lt;em&gt;logging&lt;/em&gt;) jest procesem przechwytywania informacji o aplikacji i zapisywania ich. Generalnie jest dodawane do metod które wykonują jakąś pracę i o których wykonaniu chcemy mieć informacje takie jak czas wykonania, start, ilość danych itp. Logowanie można wykonać za pomocą narzędzi zewnętrznych jak &lt;strong&gt;NLog&lt;/strong&gt; i &lt;strong&gt;Log4net&lt;/strong&gt; lub użyć przestrzeni nazw &lt;strong&gt;System.Diagnostics&lt;/strong&gt; do przechwycenia tych informacji. Większość narzędzi logujących pozwala na zapisywanie informacji wg poziomów krytyczności jak np &lt;strong&gt;Error&lt;/strong&gt;, &lt;strong&gt;Info&lt;/strong&gt; i &lt;strong&gt;Debug&lt;/strong&gt;. Pozwala to konfigurować poziom krytyczności który ma być zapisywany dla danego środowiska.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Logowanie błędów może być obsługiwane automatycznie poprzez użycie atrybutu &lt;strong&gt;HandleErrorAttribute&lt;/strong&gt;, przez nadpisanie metody kontrolera &lt;strong&gt;OnException&lt;/strong&gt; lub przez użycie własnego filtru obsługującego błędy. Przykład użycia &lt;strong&gt;HandleErrorAttribute&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[HandleError(ExceptionType=typeof(System.IOException), View="FileError")]
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład użycia metody &lt;strong&gt;OnException&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;protected override void OnException(ExceptionContext exceptionContext)
{
    if (exceptionContext.IsChildAction)
    {
        //we don't want to display the error screen if it is a child action,
        base.OnException(exceptionContext);
        return;
    }

    // log the exception in your configured logger
    Logger.Log(exceptionContext.Exception);

    //handle when the app is not configured to use the custom error path
    if (!exceptionContext.HttpContext.IsCustomErrorEnabled)
    {
        exceptionContext.ExceptionHandled = true;
        this.View("ErrorManager").ExecuteResult(this.ControllerContext);
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Zarządzanie wyjątkami może również odbywać się globalnie w metodzie &lt;strong&gt;Application_Error&lt;/strong&gt; pliku &lt;strong&gt;Global.asax&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Code contracts&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kontrakty kodu (ang. &lt;em&gt;code contracts&lt;/em&gt;) zostały dodane z &lt;strong&gt;.NET Framework 4.0&lt;/strong&gt; i są sposobem aby metoda była odpowiedzialna za definiowanie i publikowanie własnych warunków wewnętrznych. te warunki zawierają warunki wstępne (ang. &lt;em&gt;preconditions&lt;/em&gt;), które definiują akceptowane parametry metody; warunki niezmienne (ang. &lt;em&gt;invariant conditions&lt;/em&gt;) które określają definicję rzeczy które nie mogą być zmienione w czasie życia klasy; oraz warunki oczekiwane (ang. &lt;em&gt;postconditions&lt;/em&gt;) które definiują oczekiwania co do zwracanego wyniku. Kontrakty kodu zgłaszają wyjątki jeżeli warunki nie zostaną spełnione i dają instrukcje w czasie programowania o tym jakie są oczekiwania w czasie wywoływania metod kontraktowych. Narzędziem ułatwiającym pracę z kontraktami jest &lt;strong&gt;Code Contracts Editor Extensions&lt;/strong&gt; i można je pobrać z &lt;strong&gt;Visual Studio Gallery&lt;/strong&gt;. Po dodaniu tego narzędzia we właściwościach projektu pojawia się dodatkowa zakładka. Używanie kontraktów wymaga od programisty innego podejścia do zarządzania przepływem wyjątków w aplikacji. Kontrakty są sposobem na zakodowanie zależności i udostępnienie ich dla klienta metody. Stary sposób sprawdzania parametru:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;internal Article GetArticle(int id)
{
    if (id &amp;lt;= 0)
    {
        throw new ArgumentException("id");
    }
    // some work here
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Dzięki kontraktom można go zastąpić w poniższy sposób:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;internal Article GetArticle(int id)
{
    System.Diagnostics.Contracts.Contract.Requires(id &amp;gt; 0);
    // some work here
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jeżeli kontrakt nie zostanie spełniony to kod zgłosi wyjątek &lt;strong&gt;ContractException&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;Invariant conditions&lt;/strong&gt; sprawdza czy klasa nie znajduje się w niedozwolonym stanie, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[ContractInvariantMethod]
protected void ManageInvariant()
{
    System.Diagnostics.Contract.Invariant(this.Id &amp;lt; 0);
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aplikacja może naruszyć tę zasadę tylko w czasie wykonywania prywatnych metod.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kontrakt &lt;strong&gt;postconditions&lt;/strong&gt; można dodać poprzez użycie metody &lt;strong&gt;Ensures&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;internal Article GetArticle(int id)
{
    System.Diagnostics.Contracts.Contract.Requires(id &amp;gt; 0);
    System.Diagnostics.Contracts.Contract.Ensures(
        Contract.Results&amp;lt;Article&amp;gt;() != null);
    // some work here
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Więcej informacji dostępnych na stronie MSDN &lt;a href="https://www.microsoft.com/en-us/research/project/code-contracts/"&gt;Code Contracts&lt;/a&gt;&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Niepowodzenie kontraktu może być zarządzane na różne sposoby poprzez zarejestrowanie obsługi zdarzenia &lt;strong&gt;Contract.ContractFailed&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Health monitoring&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Monitorowanie stanu (ang. &lt;em&gt;Health monitoring&lt;/em&gt;) jest systemem wbudowanym w &lt;strong&gt;ASP.NET&lt;/strong&gt;, który śledzi różne zdarzenia zachodzące wewnątrz aplikacji web. Zdarzenia cyklu życia aplikacji są zgłaszane kiedy aplikacja startuje i jest zatrzymywana, w czasie procesu startu i zatrzymania i podczas regularnych kontroli. Zdarzenia bezpieczeństwa są zgłaszane kiedy próba logowania się nie powiedzie lub kiedy nieautoryzowany użytkownik próbuje otrzymać dostęp do zabezpieczonego zasobu. Błędy aplikacji pokrywają wszystkie błędy które mogą być zgłoszone. Monitorowanie jest dodawane w konfiguracji. Istnieją specjalne mapowania dla specyficznych błędów, błędów infrastruktury, błędów przetwarzania, awarii i innych zdarzeń. Każde zdarzenie może być obsługiwane inaczej poprzez odpowiednia konfigurację. &lt;strong&gt;&amp;gt;NET Framework&lt;/strong&gt; posiada przykładową kompletną konfigurację &lt;strong&gt;Web.config&lt;/strong&gt; w której można podejrzeć wszystkie możliwe zdarzenia, dostawców i inne opcje monitorowania. Przykładowy plik można znaleźć w &lt;strong&gt;%WINDIR%\Microsoft.NET\Framework\version\CONFIG&lt;/strong&gt;. Przykład konfiguracji:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;healthMonitoring&amp;gt;
    &amp;lt;bufferModes&amp;gt;
        &amp;lt;add name="Critical Notification" maxBufferSize="100" maxFlushSize="20" urgentFlushThreshold="1" regularFlushInterval="Infinite" urgentFlushInterval="00:01:00" maxBufferThreads="1" /&amp;gt;
        &amp;lt;add name="Logging" maxBufferSize="1000" maxFlushSize="200" urgentFlushThreshold="800" regularFlushInterval="00:30:00" urgentFlushInterval="00:05:00" maxBufferThreads="1" /&amp;gt;
    &amp;lt;/bufferModes&amp;gt;
    &amp;lt;providers&amp;gt;
        &amp;lt;add name="EventLogProvider" type="System.Web.Management.EventLogWebEventProvider, System.Web" /&amp;gt;
    &amp;lt;/providers&amp;gt;
    &amp;lt;profiles&amp;gt;
        &amp;lt;add name="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom="" /&amp;gt;
        &amp;lt;add name="Critical" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" custom="" /&amp;gt;
    &amp;lt;/profiles&amp;gt;
    &amp;lt;rules&amp;gt;
        &amp;lt;add name="All Errors Default" eventName="All Events" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom="" /&amp;gt;
        &amp;lt;add name="Failure Audits Default" eventName="App Lifetime Events" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom="" /&amp;gt;
    &amp;lt;/rules&amp;gt;
    &amp;lt;eventMappings&amp;gt;
        &amp;lt;add name="All Events" type="System.Web.Management.WebBaseEvent,System.Web" startEventCode="0" endEventCode="2147483647" /&amp;gt;
        &amp;lt;add name="Heartbeats" startEventCode="0" endEventCode="2147483647" type="System.Web.Management.WebHeartbeatEvent,System.Web" /&amp;gt;
        &amp;lt;add name="App Lifetime Events" startEventCode="0" endEventCode="2147483647" type="System.Web.Management.WebApplicationLifetimeEvent" /&amp;gt;
    &amp;lt;/eventMappings&amp;gt;
&amp;lt;/healthMonitoring&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Sekcja definiuje okres oczekiwania przed zapisem do dostawcy. Sekcja definiuje dostawców używanych do zapisywania zdarzeń. Sekcja pozwala zdefiniować zestawy parametrów używanych przy konfiguracji zdarzeń. Sekcja tworzy powiązanie pomiędzy dostawcami i zdarzeniami. Sekcja pokazuje, że aplikacja jest mapowana do logowania zdarzeń, heartbeats i zdarzeń cyklu życia aplikacji. Więcej na ten temat można przeczytać na stronie MSDN &lt;a href="http://www.asp.net/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/logging-error-details-with-asp-net-health-monitoring-cs"&gt;Logging Error Details with ASP.NET Health Monitoring&lt;/a&gt;&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Projektowanie strategii obsługi wyjątków&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Wyjątki są standardową częścią aplikacji. Nawet jeżeli aplikacja jest wolna od błędów to może zgłaszać wyjątki lub mogą występować inne problemy zależne od czynników zewnętrznych jak np problemy z siecią. Projektując aplikację &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; należy rozważyć potencjalne punkty w których mogą pojawić się problemy jak np wywołania serwisu sieciowego lub dostęp do plików. należy zastanowić się co zrobić w sytuacji występowania błędu, czy powiadomić o tym fakcie użytkownika a jeżeli tak to jaką informację wyświetlić. Należy również pomyśleć o opcjach odzyskiwania aby utrzymać aplikację w stanie ciągłego działania oraz o tym jakie informacje diagnostyczne należy przechwycić.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Obsługa wyjątków pomiędzy warstwami&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Zazwyczaj warstwy w wielowarstwowych aplikacjach obsługują dwa zestawy wyjątków: własne wyjątki i wyjątki z warstwy położonej bezpośrednio pod nią w stosie. Przykładowo warstwa UI nie powinna obsługiwać wyjątku zgłoszonego w warstwie dostępu do danych. taki wyjątek powinien być obsłużony w warstwie biznesowej.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Własne strony błędów&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Choć &lt;strong&gt;IIS&lt;/strong&gt; posiada własne strony błędów to jest to raczej bardzo rzadkie żeby te strony były używane przez aplikacje oraz aby prowadziły odpowiedni poziom informacji wyświetlanych użytkownikowi. W &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; można tworzyć niestandardowe strony do wyświetlania błędów. Te strony mogą być zgodne ze stylem wyglądu zdefiniowanym dla aplikacji ale pokazywać dane specyficzne dla błędu. Strony błędów można tworzyć tak jak każdą inną kombinację kontrolera i widoków. Definiuje się kontroler obsługi błędów i tworzy się widoki do zarządzania różnymi typami błędów. Odnośniki do stron błędów mogą być dodane w kodzie jak i w konfiguracji. W aplikacji &lt;strong&gt;MVC&lt;/strong&gt; można np stworzyć kontroler &lt;strong&gt;ErrorManagerController&lt;/strong&gt;, który będzie posiadał różne akcje dla każdego możliwego statusu &lt;strong&gt;HTTP&lt;/strong&gt; oraz domyślną akcję &lt;strong&gt;ServerError&lt;/strong&gt;. Strona &lt;strong&gt;Global.asax&lt;/strong&gt; jest jednym ze sposobów użycia własnych stron błędów. można użyć metody wspólnej dla &lt;strong&gt;ASP.NET&lt;/strong&gt; i &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; którą jest &lt;strong&gt;Application_Start&lt;/strong&gt;. Można również użyć metody &lt;strong&gt;Application_Error&lt;/strong&gt; która jest globalną obsługą błędów która jest wywoływana kiedy nieobsłużony wyjątek trafia do stosu aplikacji. Przykład metody &lt;strong&gt;Application_Error&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public void Application_Error(Object sender, EventArgs e)
{
    if (Server != null)
    {
        //Get the context
        HttpContext appContext = ((MvcApplication)sender).Context;
        Exception ex = Server.GetLastError().GetBaseException();
        //Log the error using the logging framework
        Logger.Error(ex);
        //Clear the last error on the server so that custom errors are not fired
        Server.ClearError();
        //forward the user to the error manager controller.
        IController errorController = new ErrorManagerController();
        RouteData routeData = new RouteData();
        routeData.Values["controller"] = "ErrorManagerController";
        routeData.Values["action"] = "ServerError";
        errorController.Execute(
            new RequestContext(new HttpContextWrapper(appContext), routeData));
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Obsługę błędów można również dodać poprzez konfigurację dodając sekcję do , np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;customErrors mode="RemoteOnly" defaultRedirect="ErrorManager/ServerError"&amp;gt;
    &amp;lt;error statusCode="400" redirect="ErrorManager/Status400" /&amp;gt;
    &amp;lt;error statusCode="403" redirect="ErrorManager/Status403" /&amp;gt;
    &amp;lt;error statusCode="404" redirect="ErrorManager/Status404" /&amp;gt;
&amp;lt;/customErrors&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Element &lt;strong&gt;customErrors&lt;/strong&gt; posiada dwa interesujące atrybuty: &lt;strong&gt;mode&lt;/strong&gt; i &lt;strong&gt;defaultRedirection&lt;/strong&gt;. Atrybut &lt;strong&gt;mode&lt;/strong&gt; może mieć trzy wartości: &lt;strong&gt;On&lt;/strong&gt;, &lt;strong&gt;Off&lt;/strong&gt; i &lt;strong&gt;RemoteOnly&lt;/strong&gt;. &lt;strong&gt;RemoteOnly&lt;/strong&gt; oznacza, że strona ma być wyświetlana dla zdalnych użytkowników a dla lokalnych będzie wyświetlana standardowa strona błędu. Atrybut &lt;strong&gt;defaultRedirection&lt;/strong&gt; jest adresem strony która będzie wyświetlona jeżeli błąd nie będzie obsługiwany przez bardziej specyficzną stronę. Błędy &lt;strong&gt;HTTP 500&lt;/strong&gt; są obsługiwane przez inne rodzaje obsługi niż konfiguracja, np przez filtry lub zdarzenie &lt;strong&gt;OnException&lt;/strong&gt;. Aby błędy były wyświetlane należy również ustawić właściwość w .&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;First chance exceptions&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Wyjątki &lt;strong&gt;First chance exceptions&lt;/strong&gt; są wyjątkami które są bezpośrednio wyrzucane, zanim zostaną obsłużone przez &lt;strong&gt;error handler&lt;/strong&gt;. Przykładem takiego wyjatku może być wyjątek zgłaszany w metodzie &lt;strong&gt;Application_Start&lt;/strong&gt; pliku &lt;strong&gt;Global.asax&lt;/strong&gt;. Można dodać obsługę takich wyjątków do aplikacji. Ta obsługa będzie wywoływana dla każdego wyjątku zgłoszonego w aplikacji. Można w niej dodać logowanie lub inną czynność diagnostyczną. Należy zwrócić szczególną uwagę aby obsługa tych wyjątków sama nie zgłaszała wyjątków ponieważ może to doprowadzić do kaskady wyjątków i spowodować przepełnienie stosu. Przykład przechwytywania &lt;strong&gt;FirstChanceExceptions&lt;/strong&gt; w &lt;strong&gt;Global.asax&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;protected void Application_Start()
{
    AppDomain.CurrentDomain.FirstChanceException +=
        CurrentDomain_FirstChanceException;

    AreaRegistration.RegisterAllAreas();
    WebApiConfig.Register(GlobalConfiguration.Configuration);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
    AuthConfig.RegisterAuth();
}
protected void CurrentDomain_FirstChanceException(object sender,
    System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e)
{
    if (e.Exception is NotImplementedException)
    {
        // do something special when the functionality is not implemented
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aby być pewnym, że &lt;strong&gt;Visual Studio&lt;/strong&gt; przechwyci &lt;strong&gt;FirstChanceException&lt;/strong&gt;,należy zaznaczyć w opcjach &lt;strong&gt;DEBUG Exceptions&lt;/strong&gt; zgłaszanie i obsługę &lt;strong&gt;Common Language Runtime Exception&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Testowanie aplikacji web&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Testowanie kodu jest jednym z podstawowych wymagań oprogramowania, ale nie jest to jeden z najbardziej powszechnie pomijanych lub minimalnie zarządzanych obszarów rozwoju oprogramowania. Jednym ze sposobów zarządzania nieoczekiwanych zdarzeń w kodzie jest pisanie i utrzymywanie testów jednostkowych. Testowanie jednostkowe to proces tworzenia testów wielokrotnego użycia które sprawdzają poprawność konkretnego podzbioru funkcjonalności. Istnieją dwa ważne aspekty wykonywania testu jednostkowego. Test powinien dokładnie pokrywać testowany obszar funkcjonalności. Testy powinny być napisane zarówno dla pozytywnego przepływu w stosie wywołań jak i negatywnego przepływu a w tym testować również przypadki wystąpienia błędu w niższej warstwie stosu.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Testy jednostkowe&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W aplikacji &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; można tworzyć testy jednostkowe dla prostych metod, modeli, metod aplikacji i akcji w kontrolerach poprzez sprawdzanie zwracanego rezultatu. W &lt;strong&gt;Visual Studio&lt;/strong&gt; można dodać projekt z testami jednostkowymi poprzez &lt;strong&gt;Add New Project | Unit Test Project&lt;/strong&gt;. Dobrą praktyką jest pisanie testów dla każdej klasy osobno i nadawanie im nazw które jednoznacznie określają co jest testowane. Przykład metody do testowania:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public double Add(object initNumber, object additional)
{
    double baseNumber = Convert.ToDouble(initNumber);
    double addingNumber = Convert.ToDouble(additional);
    return baseNumber + addingNumber;
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Gdy parametry wejściowe są nieodpowiedniego typu to zgłoszony zostanie wyjątek &lt;strong&gt;InvalidCastException&lt;/strong&gt;. Przykład testu dla tej metody:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[TestMethod]
public void Add_Test()
{
    CalculationManager manager = new CalculationManager ();
    Assert.IsTrue(manager.Add(2, 2).Equals(4), "2 + 2 = 4");
    Assert.IsTrue(manager.Add(2, 2.5).Equals(4.5), "2 + 2.5 = 4.5");
    try { manager.Add(DateTime.Now, 2.5);}
    catch (Exception ex){ Assert.IsInstanceOfType(ex,
        typeof(InvalidCastException), "Today + 2 = oops");}
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład testu akcji kontrolera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[TestMethod]
public void Index_Test()
{
    CalculationController controller = new CalculationController();
    Assert.IsInstanceOfType(controller.Index(), typeof(ExpectedViewResult));
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Testy jednostkowe powinny być wykonywane bez żadnych zależności, tzn, że powinny być niezależne od bazy danych lub UI.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Tworzenie mock’ów&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Funkcja &lt;strong&gt;Fakes&lt;/strong&gt; w &lt;strong&gt;VS 2012&lt;/strong&gt; oferuje wiele wsparcia podczas pisania testów jednostkowych. Funkcja &lt;strong&gt;Fakes&lt;/strong&gt; wprowadza dwa sposoby na zarządzanie zależnościami w czasie tworzenia testów: &lt;strong&gt;shims&lt;/strong&gt; i &lt;strong&gt;stubs&lt;/strong&gt;. &lt;strong&gt;Shim&lt;/strong&gt; jest fragmentem kodu który przechwytuje wywołanie do assembly w celu zwrócenia obiektu i zwraca jego makietę. Jest używany do zastępowania klas zewnętrznych. &lt;strong&gt;Stub&lt;/strong&gt; jest kodem który zastępuje klasę przez ograniczony podzbiór klas makiet. jest używany do zastępowania innych klas w aplikacji. Przykład użycia &lt;strong&gt;shim&lt;/strong&gt; do kontroli czasu zwracanego przez &lt;strong&gt;DateTime.Now&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;using (ShimsContext.Create())
{
    // insert the delegate that returns call for DateTime.Now
    System.Fakes.ShimDateTime.NowGet = () =&amp;gt; new DateTime(2010, 1, 1);
    MethodThatUsesDateTimeNow();
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład użycia &lt;strong&gt;stub&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public interface ICalculator
{
    double Add(double firstNumber, double lastNumber);
}

public class Mathematics
{
    private ICalculator calculator;
    public Mathematics (ICalculator calc)
    {
        calculator = calc;
    }
    public double AddNumbers()
    {
        return calculator.Add(1,1);
    }
}
// ...
[TestMethod]
public void TestAdd()
{
    // Create the fake calculator:
    ICalculator calculator = new Calculator.Fakes.StubICalculator()
    {
        // Define each method:
        Add = (a,b) =&amp;gt; { return 25; }
    };

    // In the completed application, item would be a real one:
    var item = new Mathematics(calculator);

    // Act:
    double added = item.AddNumbers();
    Assert.AreEqual(25, added);
}
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Visual Studio Web Tests&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W edycji &lt;strong&gt;Visual Studio Ultimate 2012&lt;/strong&gt; można tworzyć i uruchamiać testy wydajności i obciążenia (&lt;strong&gt;web performance tests&lt;/strong&gt; i &lt;strong&gt;load tests&lt;/strong&gt;). Pierw tworzy się testy web które chcemy uruchomić podczas trwania testu obciążenia. Te testy mogą być skalowane od jednego do wielu użytkowników aby sprawdzić jak aplikacja zachowuje się w czasie obciążenia. Liczba użytkowników może zostać ustalona na stałe lub być inkrementowana. Można również ustawić progi oparte na systemie, który będzie monitorować gdy aplikacja osiągnie próg obciążenia procesora lub pamięci. Testowanie rozwiązania obejmują test dymu, testy warunków skrajnych oraz testy wydajności (&lt;strong&gt;smoke test&lt;/strong&gt;, &lt;strong&gt;stress test&lt;/strong&gt; i &lt;strong&gt;performance test&lt;/strong&gt;). Test typu &lt;strong&gt;smoke&lt;/strong&gt; używa małego obciążenia w krótkim czasie. Można użyć go od razu po wdrożeniu aplikacji na nowe środowisko aby mieć pewność, że aplikacja działa prawidłowo. Test typu &lt;strong&gt;stress&lt;/strong&gt; uruchamia aplikację pod dużym obciążeniem przez długi okres czasu ujawniać zachowania aplikacji w warunkach dużego obciążenia. Test typu &lt;strong&gt;performance&lt;/strong&gt; bada reagowania aplikacji.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aby utworzyć testy należy dodać projekt &lt;strong&gt;Web Test and Load Project&lt;/strong&gt; po czym należy skonfigurować przepływ testów które będą używane w teście. Najprostszym sposobem jest nagranie serii akcji w aplikacji web. W nowym projekcie powinien znajdować się plik &lt;strong&gt;.webtest&lt;/strong&gt; który należy otworzyć i rozpocząć nagrywanie przepływu. Istnieją trzy podejścia przy wykonywaniu testów obciążeniowych: &lt;strong&gt;constant&lt;/strong&gt;, &lt;strong&gt;step&lt;/strong&gt; i &lt;strong&gt;goal-based&lt;/strong&gt;. Typ &lt;strong&gt;constant&lt;/strong&gt; pozwala na ustawienie stałej liczby użytkowników i użycie ich dla całego wykonania testu. Typ &lt;strong&gt;step&lt;/strong&gt; dodaje użytkowników do testu stopniowo. Należy ustawić cztery wartości dla tego testu: &lt;strong&gt;Initial user count&lt;/strong&gt;, &lt;strong&gt;Maximum user count&lt;/strong&gt;, &lt;strong&gt;Step duration&lt;/strong&gt; i &lt;strong&gt;Step user count&lt;/strong&gt;. Typ &lt;strong&gt;goal-based&lt;/strong&gt; ładuje test tak jak typ &lt;strong&gt;step&lt;/strong&gt; jednakże różni się tym, że nie zlicza uruchomionych użytkowników jako kluczowej informacji tylko zlicza użytkowników jako sposób na dotarcie do innych celów, np obciążenie procentowe CPU i procentowe zużycie pamięci.&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Debugowanie aplikacji Windows Azure&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Debugowanie aplikacji web może być dużym wyzwaniem. Dodanie aplikacji w aspekcie zdalnym do &lt;strong&gt;Windows Azure&lt;/strong&gt; może uczynić debugowanie jeszcze bardziej skomplikowanym. Dlatego na potrzeby &lt;strong&gt;Windows Azure&lt;/strong&gt; dodano dodatkowe dedykowane narzędzia diagnostyczne &lt;strong&gt;Windows Azure–specific diagnostics API, Microsoft.WindowsAzure.Diagnostics&lt;/strong&gt;. Uruchomienie diagnostyki w aplikacji wdrożonej na &lt;strong&gt;Windows Azure&lt;/strong&gt; wymaga kilku kroków. Pierw należy dodać informacje do pliku &lt;strong&gt;ServiceDefinition.csdef&lt;/strong&gt; aby można było zaimportować moduł &lt;strong&gt;Diagnostics&lt;/strong&gt;. Należy także upewnić się, że informacja jest dodana do pliku &lt;strong&gt;ServiceConfiguration.cscfg&lt;/strong&gt; aby moduł diagnostyki miał dostęp do bazy danych i innych usług biznesowych. Kiedy diagnostyka jest już dostępna w aplikacji to można ją wywołać z poziomu kodu lub użyć wbudowanego monitora zdarzeń. Aby skonfigurować nowy monitor należy utworzyć nowy plik &lt;strong&gt;Diagnostics.wadcfg&lt;/strong&gt;, który zawiera wpisy konfiguracyjne ustawiające odpowiednie liczniki. Po zapisaniu informacji diagnostycznych można programistycznie pobrać te informacje z serwera lub dostać je na żądanie. Przykład pliku &lt;strong&gt;ServiceDefinition.csdef&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;ServiceDefinition name="WindowsAzure1" xmlns=http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition schemaVersion="2013-03.2.0"&amp;gt;
    &amp;lt;WebRole name="WebRole1"&amp;gt;
        &amp;lt;!-- Other configuration information here -&amp;gt;
        &amp;lt;Imports&amp;gt;
        &amp;lt;Import moduleName="Diagnostics" /&amp;gt;
        &amp;lt;/Imports&amp;gt;
    &amp;lt;/WebRole&amp;gt;
&amp;lt;/ServiceDefinition&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład pliku &lt;strong&gt;ServiceConfiguration.cscfg&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;ServiceConfiguration serviceName="WindowsAzure2" xmlns="http://schemas.microsoft.com/ServiceHosting/
        2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0"&amp;gt;
    &amp;lt;Role name="WebRolePrimary"&amp;gt;
        &amp;lt;Instances count="1" /&amp;gt;
        &amp;lt;ConfigurationSettings&amp;gt;
            &amp;lt;Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /&amp;gt;
            &amp;lt;!—- this version is for deployment on the azure server
            &amp;lt;Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics
                .ConnectionString" value="DefaultEndpointsProtocol
                =https;AccountName=demoapp;AccountKey=[your key]" /&amp;gt; --&amp;gt;
        &amp;lt;/ConfigurationSettings&amp;gt;
    &amp;lt;/Role&amp;gt;    
&amp;lt;/ServiceConfiguration&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład dodania dwóch liczników wydajności w pliku &lt;strong&gt;Diagnostics.wadcfg&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;DiagnosticMonitorConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration" configurationChangePollInterval="PT1M" overallQuotaInMB="4096"&amp;gt;

    &amp;lt;PerformanceCounters bufferQuotaInMB="0" scheduledTransferPeriod="PT30M"&amp;gt;
        &amp;lt;PerformanceCounterConfiguration counterSpecifier="\Process(WaWorkerHost)\Thread Count" sampleRate="PT30S" /&amp;gt;
        &amp;lt;PerformanceCounterConfiguration counterSpecifier="\.NET CLR Interop(_Global_)\# of marshalling" sampleRate="PT30S" /&amp;gt;
    &amp;lt;/PerformanceCounters&amp;gt;

    &amp;lt;DiagnosticInfrastructureLogs bufferQuotaInMB="0" scheduledTransferLogLevelFilter="Verbose" scheduledTransferPeriod="PT30M" /&amp;gt;

&amp;lt;/DiagnosticMonitorConfiguration&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W &lt;strong&gt;Windows Azure&lt;/strong&gt; można również skonfigurować &lt;strong&gt;IntelliTrace&lt;/strong&gt; dla aplikacji. Aby tego dokonać należy wdrożyć aplikację używając &lt;strong&gt;Visual Studio Ultimate 2012&lt;/strong&gt; i dodać pewne zmiany w czasie konfiguracji wdrożenia. Informacje zbierane przez &lt;strong&gt;IntelliTrace&lt;/strong&gt; mogą być pobrane za pomocą &lt;strong&gt;Visual Studio&lt;/strong&gt;. Należy zaznaczyć pole wyboru &lt;strong&gt;Enable IntelliTrace&lt;/strong&gt; i wybrać informacje które mają być zbierane. Do wyboru są dwie główne kategorie: tylko zdarzenia lub zdarzenia i informacje o wywołaniach. Wybranie tylko zdarzeń ma minimalny wpływ na wydajność aplikacji lecz zbieranie informacji o wywołaniach ze zdarzeniami może mieć duży wpływ na działanie aplikacji. Po pobraniu kopii dzienników można otworzyć je w oknie &lt;strong&gt;Server Explorer&lt;/strong&gt; wybierając &lt;strong&gt;Windows Azure Compute&lt;/strong&gt;.&lt;/p&gt;
&lt;div style="height: 0; width: 0; max-height: 0; max-width: 0; overflow: hidden; font-size: 0em; padding: 0; margin: 0;"&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 11 Aug 2016 20:00:59 Z</pubDate>
      <a10:updated>2016-08-11T20:00:59Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1132</guid>
      <link>http://smsoft.pl/blog/iii-programowanie-interfejsu-uzytkownika/</link>
      <title>III. Programowanie interfejsu użytkownika</title>
      <description>&lt;div&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Doświadczenie użytkownika końcowego aplikacji jest bardzo istotne, szczególnie dla stron internetowych. Wiele czynników wpływa na UX.&lt;/p&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Optymalizacja SEO&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wiele firm, szczególnie e-comerce, opierają się na wyszukiwarkach aby pomóc użytkownikom dostać się do ich stron.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;W ramach swoich działań &lt;strong&gt;SEO&lt;/strong&gt;, trzeba usunąć przeszkody, które mogłyby utrudnić wyszukiwarkom skuteczne zindeksowanie witryny. należy upewnić się, że w kodzie nie ma brakujących lub niekompletnych tagów &lt;strong&gt;HTML&lt;/strong&gt; oraz, że treść jest odseparowana od prezentacji i skryptów. Jest to bardzo istotne ponieważ większość kodu &lt;strong&gt;HTML&lt;/strong&gt; jest tworzone przez helpery i jest współdzielona z szablonów i nie jest zwykle sprawdzana.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Narzędzia analityczne pomagają sprawdzić poprawność kodu &lt;strong&gt;HTML&lt;/strong&gt; w aplikacji. Należą do nich &lt;strong&gt;IIS SEO Toolkit&lt;/strong&gt; i &lt;strong&gt;Internet Explorer Developer Toolbar&lt;/strong&gt;. &lt;strong&gt;W3C&lt;/strong&gt; posiada walidator sieciowy który sprawdza poprawność &lt;strong&gt;HTML&lt;/strong&gt; i &lt;strong&gt;CSS&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;IIS SEO Toolkit&lt;/strong&gt; nie jest narzędziem wbudowanym w &lt;strong&gt;IIS&lt;/strong&gt;. Należy go pobrać ze strony &lt;em&gt;Microsoft.com&lt;/em&gt;. Można dzięki niemu analizować strony i aplikacje, tworzyć mapy stron oraz tworzyć zasady wykluczeń dla robotów a także pliku &lt;strong&gt;robots.txt&lt;/strong&gt; w którym definiujemy które strony nie powinny być zindeksowane.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Technologia jest ciągle ulepszana, pozwalając ludziom z upośledzeniami używać internetu coraz bardziej skutecznie. &lt;strong&gt;WAI-ARIA&lt;/strong&gt; jest systemem znaczników który wspomaga technologię i pozwala użytkownikom na lepsze zrozumienie treści. Przykład kodu &lt;strong&gt;HTML&lt;/strong&gt; z &lt;strong&gt;ARIA&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;ARIA Example: Hello&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div role="application"&amp;gt;
        &amp;lt;div id="name" class="name"&amp;gt;
            &amp;lt;h2&amp;gt;Hello&amp;lt;/h2&amp;gt;
            &amp;lt;p&amp;gt;
                &amp;lt;strong&amp;gt;Instructions:&amp;lt;/strong&amp;gt; Insert your name in the box below. An
                &amp;lt;abbr title="Accessible Rich Internet Application"&amp;gt;ARIA&amp;lt;/abbr&amp;gt; dialog box will display the result. To start over, press the Try Again button.
            &amp;lt;/p&amp;gt;
            &amp;lt;p class="input"&amp;gt;
                &amp;lt;label id="name_label" for="name_text"&amp;gt;Insert your Name:&amp;lt;/label&amp;gt;
                &amp;lt;input type="text" id="name_text" size="3" aria-labelledby="name_label" aria-invalid="false" /&amp;gt;
            &amp;lt;/p&amp;gt;
            &amp;lt;p id="name_alert" role="alert" class="feedback"&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;p class="input"&amp;gt;
                &amp;lt;input class="button" id="name_check" type="button" role="button" aria-pressed="false" value="Check Name" /&amp;gt;
                &amp;lt;input class="button" id="name_again" type="button" role="button" aria-pressed="false" value="Try Again" /&amp;gt;
            &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; nie posiada wbudowanego wsparcia dla &lt;strong&gt;ARIA&lt;/strong&gt; ale rozszerzalna natura &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; pozwala na utworzenie helperów &lt;strong&gt;HTML&lt;/strong&gt; zgodnych z &lt;strong&gt;ARIA&lt;/strong&gt;, np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public static IHtmlString ARIATextBoxFor&amp;lt;TModel, TProperty&amp;gt;(this HtmlHelper&amp;lt;TModel&amp;gt;
    helper, Expression&amp;lt;Func&amp;lt;TModel, TProperty&amp;gt;&amp;gt; exp)
{
    ModelMetadata metadata = ModelMetadata.FromLambdaExpression(exp,
        helper.ViewData);
    var attr = new RouteValueDictionary();
    if (metadata.IsRequired)
    {
        attr.Add("aria-required", true);
    }
    return helper.TextBoxFor(exp, attr);
}
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Globalizacja i lokalizacja&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Globalizacja jest przygotowaniem technicznym aplikacji do wsparcia wielu kultur i dzieli się na umiędzynarodowienie (&lt;strong&gt;I18N&lt;/strong&gt;) i lokalizację. Umiędzynarodowienie jest procesem w którym przystosowujemy aplikację do obsługi wielu kultur. Lokalizacja jest procesem tworzenia treści specyficznej dla danej lokalizacji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;najwyższym poziomem lokalizacji jest język. Podkategorią języka jest narodowość np j. angielski jest inny w UK i USA. Oba są tym samym językiem ale mają swoje kody narodu &lt;strong&gt;US&lt;/strong&gt; i &lt;strong&gt;UK&lt;/strong&gt;. kiedy aplikacja obsługuje globalizację to w pierwszej kolejności wyszukuje tłumaczenia dla narodowości a później dla języka a na końcu w języku domyślnym. Kiedy żądanie &lt;strong&gt;HTTP&lt;/strong&gt; jest wysyłane do serwera to zawiera nagłówek podobny do poniższego:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;GET http://localhost/HTTP/1.1
Connection: keep-alive
Cache-Control: max-age=0
Accept-Language: en-US,en;q=0.8
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aby aplikacja mogła to obsłużyć należy dodać do pliku &lt;strong&gt;Web.config&lt;/strong&gt; wpis:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;globalization culture="auto" uiculture="auto" enableclientbasedculture="true"/&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;To ustawienie mówi &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; aby automatycznie ustawić narodowość klienta i po otrzymaniu żądania w innym języku niż domyślny &lt;strong&gt;ASP.NET&lt;/strong&gt; ładuje tę informację do właściwości &lt;strong&gt;CurrentThread.CurrentUICulture&lt;/strong&gt;.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Globalizacja wymaga aby wszystkie treści które mogą być wyświetlane zostały umieszczone w plikach zasobów. Przy tworzeniu plików zasobów powinno unikać się powtórzeń ponieważ zwiększają one koszt tłumaczenia. klasa pomocnicza &lt;strong&gt;ResourceManager&lt;/strong&gt; pomaga zwrócić przetłumaczone zasoby. &lt;strong&gt;ResourceManager&lt;/strong&gt; pobiera język z klasy &lt;strong&gt;CultureInfo&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Alternatywą dla plików z zasobami jest tworzenie osobnych stron dla różnych języków. Aby użyć tego podejścia należy nadpisać metodę &lt;strong&gt;Controller.OnActionExecuted&lt;/strong&gt; tak aby budowała ścieżkę do widoku na podstawie klasy &lt;strong&gt;UICulture&lt;/strong&gt; aktualnego wątku.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;W &lt;strong&gt;ASP.NET&lt;/strong&gt; zaleca się aby pliki zasobów były rozdzielone na języki a sugerowana konwencja nazewnictwa to .&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Pliki zasobów mogą być używane przez wiele widoków. Dla języków zachodnich w których czyta się zwykle od prawej do lewej trzeba użyć innego zestawu widoków.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Należy zapewnić zasoby globalizacji dla &lt;strong&gt;jQuery&lt;/strong&gt;. &lt;strong&gt;Java Script&lt;/strong&gt; nie może pobrać kultury z przeglądarki, nawet jeżeli ta informacja jest dostępna i przesyłana przez przeglądarkę. &lt;em&gt;Microsoft&lt;/em&gt; utworzył moduł globalizacji dla &lt;strong&gt;jQuery&lt;/strong&gt;. Przykład dołączenia plików &lt;strong&gt;JS&lt;/strong&gt; dla globalizacji:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;script src="scripts/jquery.globalize/globalize.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="scripts/jquery.globalize/cultures/globalize.cultures.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aby używać języka po stronie klienta należy zapisać go do zmiennej np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;var language = "@Request.UserLanguages[0]";
jQuery.preferCulture(language);
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Lub ustawić jako język w przestrzeni globalnej:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;$.global.preferCulture(language)
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Można umożliwić użytkownikom wybór kultury w której chcą obsługiwać aplikację. kiedy użytkownik wybierze narodowość to można ją zapisać w sesji lub jako ciasteczko. Później należy nadpisać domyślny jeżyk z przeglądarki przez język wybrany przez użytkownika. Dobrym miejscem na nadpisanie języka jest filtr akcji, np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-MX");
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Pliki z zasobami można aktualizować lub tworzyć z pomocą narzędzi takich jak &lt;strong&gt;Assembly Linker&lt;/strong&gt; i &lt;strong&gt;Resource File Generator&lt;/strong&gt;. przykład utworzenia pliku tłumaczen przez &lt;strong&gt;Assembly Linker&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;al.exe /t:lib /embed:strings.de-DE.resources /culture:de-DE /out:MyApp.de-DE.resources.dll
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Implementacja kontrolerów i akcji MVC&lt;/h2&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Atrybuty i filtry&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Atrybuty filtrów pozwalają na zbadanie i podjęcie akcji na podstawie informacji zawartych w żądaniu przed i po wywołaniu akcji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; posiada wbudowane atrybuty pomagające przy uwierzytelnieniu, autoryzacji, zabezpieczeniu dostępu i zarządzaniu błędami. jeżeli istnieje taka potrzeba to można zbudować własne filtry.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Główną rolą atrybutów jest analiza informacji, szczególnie zawartych w klasie &lt;strong&gt;HttpContext&lt;/strong&gt;, przychodzących i wychodzących z kontrolera.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Atrybuty filtrów dziedziczą z klasy &lt;strong&gt;System.Web.Mvc.FilterAttribute&lt;/strong&gt; i pozwalają programiście na wstawienie pewnej logiki do przetwarzania akcji kontrolerów.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Jeden zestaw atrybutów standardowych zawiera tradycyjne filtry sprawdzające pewne oczekiwania . Są to filtry &lt;strong&gt;RequireHttpsAttribute&lt;/strong&gt;, &lt;strong&gt;ValidateAntiForgeryTokenAttribute&lt;/strong&gt;, &lt;strong&gt;ValidateInputAttribute&lt;/strong&gt;, &lt;strong&gt;AuthorizeAttribute&lt;/strong&gt;, &lt;strong&gt;AllowAnonymous&lt;/strong&gt; i &lt;strong&gt;ChildActionOnlyAttribute&lt;/strong&gt;. Wszystkie można znaleźć w przestrzeni nazw &lt;strong&gt;System.Web.Mvc&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Filtry &lt;strong&gt;HandleErrorAttribute&lt;/strong&gt; i &lt;strong&gt;ActionFilterAttribute&lt;/strong&gt; są bardziej podobne do kodu otaczającego akcję niż do filtrów. Pierwszy obsługuje wyjątki występujące w akcjach, domyślnie w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; wyświetlany jest widok &lt;strong&gt;~/Views/Shared/Error&lt;/strong&gt;. Filtr ten pozwala na użycie różnych widoków dla różnych wyjątków. Aby zmienić jego zachowanie należy przesłonić metodę &lt;strong&gt;OnException&lt;/strong&gt; atrybutu. Atrybut &lt;strong&gt;ActionFilterAttribute&lt;/strong&gt; jest klasą abstrakcyjną z której filtry dziedziczą. Pozwala ona na tworzenie własnych filtrów i klas które mogą być atrybutami akcji. podstawowe metody do nadpisania to:&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;OnActionExecuting&lt;/strong&gt; - wywoływana przed wywołaniem akcji. Pozwala na zbadanie informacji dostępnych w &lt;strong&gt;HttpContext&lt;/strong&gt; i podjęcie decyzji czy akcja powinna być kontynuowana.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;OnActionExecuted&lt;/strong&gt; - pozwala zbadać wynik akcji i zdecydować czy coś musi sie wydarzyć w tym punkcie.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;OnResultExecuting&lt;/strong&gt; - wywoływana przed przetworzeniem wyniku akcji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;OnResultExecuted&lt;/strong&gt; - wywoływana po przetworzeniu wyniku akcji ale przed załadowaniem wyniku do strumienia wyjściowego.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Atrybuty akcji mogą być zamieszczone w trzech miejscach. Dla poszczególnych akcji kontrolerów. Dla klasy kontrolera co spowoduje, że zostaną zastosowane dla wszystkich akcji kontrolera. Globalnie co spowoduje, ze wszystkie akcje aplikacji będą używać tego filtru. Aby dodać filtr globalny należy dodać linię kodu w metodzie &lt;strong&gt;RegisterGlobalFilters&lt;/strong&gt; w pliku &lt;strong&gt;App_Start/FilterConfig.cs&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;filters.Add(new RequireHttpsAttribute());
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Implementacja akcji i wyników akcji&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; zapewnia programistom dużą elastyczność w jaki sposób mogą one przetwarzać przychodzące żądania . początkowa granica akcji rozpoczyna się w momencie w którym &lt;strong&gt;routing&lt;/strong&gt; okresli która akcja musi być wywołana aby pasowała do ścieżki URL. Ta początkowa granica zawiera również dopasowanie parametrów wejściowych. kiedy decyzja o trasie jest podjęta to przepływ zostaje przekazany do obsługi zdarzeń i atrybutów filtrów.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wynikiem akcji aplikacji &lt;strong&gt;MVC&lt;/strong&gt; są wyniki akcji &lt;strong&gt;Action results&lt;/strong&gt;. Są one ostatnim krokiem obsługi &lt;strong&gt;HttpRequest&lt;/strong&gt; i są odpowiedzialne za zapis informacji do strumienia odpowiedzi.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Powszechnie stosowany wynik &lt;strong&gt;ViewResultBase&lt;/strong&gt; jest bazowym wynikiem zwracającym &lt;strong&gt;HTML&lt;/strong&gt; do klienta.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ViewResult&lt;/strong&gt; i &lt;strong&gt;PartialViewResult&lt;/strong&gt; dziedziczą z &lt;strong&gt;ViewResultBase&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Jeżeli akcja zwraca plik to istnieją wyniki akcji &lt;strong&gt;FileResult&lt;/strong&gt; i &lt;strong&gt;ContentResult&lt;/strong&gt;, pierwszy dla treści binarnej a drugi dla ASCII. Zwracając &lt;strong&gt;ContentResult&lt;/strong&gt; należy zdefiniować treść jako ciąg znaków, podać kodowanie i określić typ treści &lt;strong&gt;ContentType&lt;/strong&gt; np &lt;strong&gt;application/pdf&lt;/strong&gt;. &lt;strong&gt;FileResult&lt;/strong&gt; wymaga podania &lt;strong&gt;ContentType&lt;/strong&gt; i &lt;strong&gt;FileDownloadName&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;JavaScriptResult&lt;/strong&gt; i &lt;strong&gt;JsonResult&lt;/strong&gt; są zaprojektowane tak aby wspierać przetwarzanie po stronie klienta poprzez zwracanie kodu &lt;strong&gt;JavaScript&lt;/strong&gt; lub obiektów &lt;strong&gt;JSON&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;RedirectResult&lt;/strong&gt; i &lt;strong&gt;RedirectToRouteResult&lt;/strong&gt; przekierowują przetwarzanie do innego adresu &lt;em&gt;URL&lt;/em&gt; lub innej akcji &lt;em&gt;MVC&lt;/em&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;EmptyResult&lt;/strong&gt; reprezentuje brak wyniku.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Implementacja wiązania danych&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Model binding&lt;/strong&gt; jest elastycznym procesem który mapuje pola w interfejsie użytkownika na właściwości modelu. Istnieją trzy typy wiązania modelu: &lt;strong&gt;strongly-typed binding&lt;/strong&gt;, &lt;strong&gt;weakly-typed binding&lt;/strong&gt;, i &lt;strong&gt;using the value provider&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Strongly-typed binding&lt;/strong&gt; jest narzędziem działającym w dwie strony w taki sposób, że helper HTML rozumie atrybuty w modelu i może ustawić sprawdzanie danych po stronie klienta bazując na tych informacjach. Framework może zidentyfikować te informacje kiedy są przesyłane z powrotem do metody akcji. W modelu można używać atrybutów sprawdzających poprawność danych jak np &lt;strong&gt;Required&lt;/strong&gt; lub &lt;strong&gt;DataType(DataType.Password)&lt;/strong&gt;. Przykład silnie typowanego wiązania pola tekstowego:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@Html.TextBoxFor(m =&amp;gt; m.UserName)
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Do klas wiązania danych należą: &lt;strong&gt;DefaultModelBinder&lt;/strong&gt;, &lt;strong&gt;LinqBinaryModelBinder&lt;/strong&gt;, &lt;strong&gt;ModelBinderAttribute&lt;/strong&gt; i &lt;strong&gt;ModelBinderDictionary&lt;/strong&gt;.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Weakly-typed binding&lt;/strong&gt; jest wiązaniem jednostronnym które nie dostarcza sprawdzania danych po stronie klienta ale tworzy model kiedy żądanie jest zwracane. Można dodać helpery pomocnicze w &lt;strong&gt;Weakly-typed binding&lt;/strong&gt; oraz dodać listę akceptowanych i blokowanych atrybutów które powinny być wypełniane z formularza poprzez użycie parametrów &lt;strong&gt;Include&lt;/strong&gt; i &lt;strong&gt;Exclude&lt;/strong&gt; w atrybucie &lt;strong&gt;Bind&lt;/strong&gt;. Przykład:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@Html.TextBox("model.UserName")
// ...
Public ActionResult Login([Bind(Prefix="login")]LoginUser user)
// ...
Public ActionResult Save([Bind(Exclude="Salary")]Employee emp)
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Kiedy nie mamy dostępu do wiązania typów z formularzem a otrzymujemy żądanie &lt;strong&gt;POST&lt;/strong&gt; to możemy użyć obiektu &lt;strong&gt;ValueProvider&lt;/strong&gt; aby umożliwić wiązanie do modelu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Istnieją cztery główne rodzaje wiązania &lt;strong&gt;ValueProvider&lt;/strong&gt; w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; wyspecjalizowane w wiązaniu innych stosów żądań.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;FormsValueProvider&lt;/strong&gt; pozwala na pracę z danymi zwracanymi jako wartości formularza.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;QueryStringProvider&lt;/strong&gt; pozwala na pracę z danymi zawartymi w &lt;strong&gt;query string&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;HttpFileCollectionValueProvider&lt;/strong&gt; - pozwala na pracę z załącznikami zawartymi w żądaniu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;RouteDataValueProvider&lt;/strong&gt; - pozwala na pracę z danymi trasowania lub URL.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Dane zwracane przez wybranego dostawcę można wiązać z modelem używając metody rozszerzającej &lt;strong&gt;ToValueProvider&lt;/strong&gt; obiektu &lt;strong&gt;FormCollection&lt;/strong&gt;. ten proces próbuje dopasować pola z wartością do pustego modelu.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;Public ActionResult Save(FormCollection formColl)
{
    Employee emp = new Employee();
    If (TryUpdateModel(emp, formColl.ToValueProvider())
    {
        UpdateModel(emp, formColl.ToValueProvider());
    }
    // more code here
}
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Routing&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Jeżeli w aplikacji istotne jest &lt;strong&gt;SEO&lt;/strong&gt; to rozważ nadawanie adresów &lt;strong&gt;URL&lt;/strong&gt; zrozumiałych dla człowieka np &lt;em&gt;Product/&lt;/em&gt; zamiast &lt;em&gt;Product/1&lt;/em&gt;. Jeżeli powiązanie pomiędzy adresem &lt;strong&gt;URL&lt;/strong&gt; a treścią strony nie jest jasne to może być wymagane wsparcie dla wielu różnych dróg do dotarcia do określonej strony, np wg tytułu, ISBN lub nazwy autora. Odpowiednio skonfigurowany routing pomaga aplikacji szybko zdecydować która akcja powinna obsłużyć żądanie.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Kolejność tras zawartych w &lt;strong&gt;RouteCollection&lt;/strong&gt; lub tablicy routingu jest istotna. Routing wyszukuje na liście tras pierwszego dopasowania dla przychodzącego wzoru. Lista tras powinna zaczynać się od ignorowanych adresów, potem bardziej specyficzne adresy a na końcu adresy ogólne. Domyślna obsługa tras jest zapisana w metodzie &lt;strong&gt;RegisterRoutes&lt;/strong&gt; w pliku &lt;strong&gt;App_Start/RouteConfig.cs&lt;/strong&gt;. Aby dodać trasę do &lt;strong&gt;RouteCollection&lt;/strong&gt; użyj funkcji &lt;strong&gt;MapRoute&lt;/strong&gt;. Metoda ta przyjmuje nazwę i wzór adresu jako parametry wymagane oraz domyśle wartości i ograniczenia jako parametry dodatkowe.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;p style="margin: 0.5em 0px !important;"&gt;Tworząc trasę można dodać domyślne wartości które mają zastąpić brakujące części w adresie &lt;strong&gt;URL&lt;/strong&gt;. Jako częśc tej operacji można oznaczyć parametry jako opcjonalne tak aby obsługa routingu wiedziała żeby sprawdzić przesłonięte metody z innymi parametrami. Można również użyć tej strategii aby obsłużyć specjalne wymagania jak np tworzenie prostych adresów &lt;strong&gt;URL&lt;/strong&gt; które serwer będzie tłumaczył na bardziej złożoną kombinację kontrolerów i akcji. Przykład &lt;strong&gt;RouteConfig.cs&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public static void RegisterRoutes(RouteCollection routes)
{
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { controller = "Home",
          action = "Index", id = UrlParameter.Optional },
      constraints: new { id = @"\d+" }
  );
}
&lt;/pre&gt;
&lt;p style="margin: 0.5em 0px !important;"&gt;Enumeracja &lt;strong&gt;UrlParameter.Optional&lt;/strong&gt; oznacza, że parametr jest parametrem opcjonalnym.&lt;/p&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;p style="margin: 0.5em 0px !important;"&gt;Ograniczenia (ang. &lt;em&gt;constraints&lt;/em&gt;) są sposobem na filtrowania żądanych adresów &lt;strong&gt;URL&lt;/strong&gt; i zdefiniowania innego routingu dla elementów w oparciu o ich typ lub zawartość. Obsługa routingu traktuje ograniczenia jako wyrażenie regularne i wylicza odpowiednią zmienną w celu ustalenia, czy istnieje dopasowanie. Powszechnie stosowanym ograniczeniem jest ograniczenie trasy tylko do takich w których jako odpowiedni segment adresu rozpoznano liczbę, generalnie do wyszukiwania id, np: &lt;strong&gt;constraints: new { id = @”\d+” }&lt;/strong&gt;. Przykład tras określających różne metody dla różnych typów parametru:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;routes.MapRoute(
  name: "Videos",
  url: "Product/Details/{id}",
  defaults: new { controller = "DVD", action = "Index",
  Page = UrlParameter.Optional },
  constraints: new { id = @"[a-zA-Z]+"}
);
routes.MapRoute(
  name: "Videos2",
  url: "Product/Details/{id}",
  defaults: new { controller = "DVD", action = "Details",
  Page = UrlParameter.Optional },
  constraints: new { id = @"\d+" }
);
&lt;/pre&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;W aplikacji &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; można również zdefiniować trasy które mają być ignorowane. Służy do tego metoda &lt;strong&gt;IgnoreRoute&lt;/strong&gt;. Ponieważ routing analizuje trasy w kolejności to trasy ignorowane powinny znajdować się przed trasami które chcesz zidentyfikować jako akcje. Ponieważ &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; opiera się na &lt;strong&gt;IIS&lt;/strong&gt; to żądanie do poszczególnego pliku przechodzi przez obsługę tras &lt;strong&gt;MVC&lt;/strong&gt; ponieważ adres &lt;strong&gt;URL&lt;/strong&gt; nie jest rozpoznawany przez &lt;strong&gt;IIS&lt;/strong&gt; jako taki który powinien przejść przez &lt;strong&gt;MvcHttpHandler&lt;/strong&gt;. Wzór dopasowania dla plików ignorowanych jest troszkę inny od mapowania. Poniższy przykład ignoruje żądania do stron &lt;strong&gt;.htm&lt;/strong&gt; lub &lt;strong&gt;.html&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;routes.Ignore("{*allhtml}", new {allhtml=@".*\.htm(/.*)?});
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Duże i złożone aplikacje &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; mogą wymagać obsługi setek akcji w kontrolerach. Podział na obszary (ang. &lt;em&gt;area&lt;/em&gt;) umożliwia podział funkcjonalności na grupy logiczne. Tworzy to nowe kopie folderów dla modeli, widoków i kontrolerów w folderze obszaru. Każdy obszar ma swój routing odseparowany od innych obszarów. Obszary są rozdzielone w aplikacji poprzez &lt;strong&gt;AreaName/Controller/Action&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Punkty rozszerzalności MVC&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; zapewnia programistom wielu punktach rozszerzalności które umożliwiają wstawienie potrzebnej funkcjonalności do aplikacji. W czasie przetwarzania żądania można przechwycić je i rozszerzyć w każdym kroku.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Action Filters&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jednym z najpotężniejszych punktów rozszerzalności i najczęściej wykorzystywanym jest możliwość używania filtrów akcji (ang. &lt;em&gt;action filter&lt;/em&gt;). Można nadpisać istniejące filtry lub stworzyć własne implementując interfejs &lt;strong&gt;IActionFilter&lt;/strong&gt; i przypisując go kiedy jest wymagany. Filtry akcji pozwalają dostać się do stosu przetwarzania, zanim akcja zostanie wykonana, lub bezpośrednio po wykonaniu akcji. Cztery główne typy filtrów to:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Authorization&lt;/strong&gt; - jest zaimplementowany w&lt;strong&gt;System.Web.Mvc.IAuthorizationFilter&lt;/strong&gt; i ma na celu ocenę bezpieczeństwa oparte o to, czy metody powinny być wykonywane w zależności od uwierzytelnienia i uprawnień.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Action&lt;/strong&gt; - jest zaimplementowany w &lt;strong&gt;System.Web.Mvc.IActionFilter&lt;/strong&gt; i pozwala programiście na otoczenie wykonania akcji przez dodatkową logikę a w tym wprowadzić dodatkowe informacje do akcji, przetestować dane wchodzące i wychodzące oraz przerwanie wykonania akcji. Posiada dwie metody: &lt;strong&gt;OnActionExecuting&lt;/strong&gt;, która jest wykonywana kiedy akcja jest wywoływana i &lt;strong&gt;OnActionExecuted&lt;/strong&gt;, która jest wywoływana po wykonaniu akcji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Result&lt;/strong&gt; - jest zaimplementowany w &lt;strong&gt;System.Web.Mvc.IResultFilter&lt;/strong&gt; i otacza wynik zwracany przez akcję. Pozwala na wykonanie dodatkowego przetwarzania wyniku akcji. Posiada on dwie metody: &lt;strong&gt;OnResultExecuting&lt;/strong&gt;, która jest wywoływana przed wykonaniem wyniku i &lt;strong&gt;OnResultExecuted&lt;/strong&gt;, która jest wywoływana kiedy wynik zakończyła realizację.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Exception&lt;/strong&gt; - zaimplementowany w &lt;strong&gt;System.Web.Mvc.IExceptionFilter&lt;/strong&gt; i jest wykonywany kiedy zgłoszony zostanie nieobsłużony wyjątek w jakimkolwiek etapie życia akcji.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Controller factory&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; można utworzyć własną fabrykę kontrolerów (ang. &lt;em&gt;controller factory&lt;/em&gt;), która pozwala na wykonywanie nietradycyjnych decyzje o tym, jak są skonstruowane kontrolery. Takie podejście jest użyteczne kiedy trzeba przekazać pewne informacje jak np zależności lub referencje w czasie wykonywania. Najczęstszym powodem utworzenia fabryki jest wsparcie dla &lt;strong&gt;Dependency Injection (DI)&lt;/strong&gt; i &lt;strong&gt;Inversion of Control (IoC)&lt;/strong&gt;. Utworzenie własnej fabryki wymaga zaimplementowania interfejsu &lt;strong&gt;Web.Mvc.IControllerFactory&lt;/strong&gt;. Interfejs ten posiada trzy metody:&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;CreateController&lt;/strong&gt; - obsługuje tworzenie kontrolerów.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ReleaseController&lt;/strong&gt; - czyści zasoby kontrolera.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;GetControllerSessionBehavior&lt;/strong&gt; - definiuje i kontroluje współpracę kontrolera z sesją. Po utworzeniu fabryki kontrolerów trzeba ją zarejestrować w metodzie &lt;strong&gt;Application_Start&lt;/strong&gt; pliku &lt;strong&gt;Global.asax&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;ControllerBuilder.Current.SetControllerFactory(
    typeof(MyCustomControllerFactory());
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Action results&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Poza zdefiniowanymi wynikami akcji w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; można utworzyć własne wyniki poprzez dziedziczenie z klasy &lt;strong&gt;System.Web.Mvc.ActionResult&lt;/strong&gt; i nadpisanie metody &lt;strong&gt;ExecuteResult&lt;/strong&gt;, np:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class CustomResult&amp;lt;T&amp;gt; : ActionResult
{
    public T Data { private get; set; }

    public override void ExecuteResult(ControllerContext context)
    {
        // do work here
        string resultFromWork = "work that was done";
        context.HttpContext.Response.Write(resultFromWork);
    }
}
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;View engines&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Nadpisanie silnika widoków pozwala na wtrącenie dodatkowej logiki w czasie renderowania HTML. Można również stworzyć i zarejestrować swój własny silnik widoków. Oba główne silniki widoków dziedziczą z klasy abstrakcyjnej &lt;strong&gt;System.Web.Mvc.VirtualPathProviderViewEngine&lt;/strong&gt;. W zależności od tego co ma zostać zmienione w silniku można pominąć klasę &lt;strong&gt;VirtualPathProviderViewEngine&lt;/strong&gt; i stworzyć własną implementację interfejsu &lt;strong&gt;System.Web.Mvc.IViewEngine&lt;/strong&gt; który posiada trzy metody: &lt;strong&gt;FindView&lt;/strong&gt;, &lt;strong&gt;FindPartialView&lt;/strong&gt; i &lt;strong&gt;ReleaseView&lt;/strong&gt;. Można również nadpisać któryś z istniejących silników.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład własnego silnika widoków:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class CustomViewEngine : VirtualPathProviderViewEngine
{
    public MyViewEngine()
    {
        this.ViewLocationFormats = new string[]
            { "~/Views/{1}/{2}.mytheme ", "~/Views/Shared/{2}.mytheme" };
        this.PartialViewLocationFormats = new string[]
            { "~/Views/{1}/{2}.mytheme ", "~/Views/Shared/{2}. mytheme " };
    }

    protected override IView CreatePartialView
        (ControllerContext controllerContext, string partialPath)
    {
        var physicalpath =
            controllerContext.HttpContext.Server.MapPath(partialPath);
        return new myCustomView (physicalpath);
    }

    protected override IView CreateView
        (ControllerContext controllerContext, string viewPath, string masterPath)
    {
        var physicalpath = controllerContext.HttpContext.Server.MapPath(viewPath);
        return new myCustomView(physicalpath);
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przed użyciem własnego silnika trzeba go zarejestrować w metodzie &lt;strong&gt;Application_Start&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;ViewEngines.Engines.Add(new CustomViewEngine());
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;W trakcie tworzenia własnego silnika widoków może okazać się konieczne utworzenie klasy widoku lub dodanie funkcjonalności do istniejącej klasy. Praca która wyświetla i przesyła informacje o stronie do odpowiedzi jest wykonywana w tej klasie. Utworzenie własnej klasy widoku wymaga zaimplementowania interfejsu &lt;strong&gt;System.Web.Mvc.IView&lt;/strong&gt; i metody &lt;strong&gt;Render&lt;/strong&gt;, która pobiera jako parametry &lt;strong&gt;System.IO.TextWriter&lt;/strong&gt; i &lt;strong&gt;System.Web.Mvc.ViewContext&lt;/strong&gt; (&lt;strong&gt;ViewContext&lt;/strong&gt; zawiera informacje o obiektach &lt;strong&gt;HttpContext&lt;/strong&gt;, &lt;strong&gt;ViewBag&lt;/strong&gt; i &lt;strong&gt;FormData&lt;/strong&gt;). Obiekt &lt;strong&gt;TextWriter&lt;/strong&gt; jest narzędziem które jest używane do pobrania informacji, parsowania i wstawienia ich do obiektu &lt;strong&gt;HttpResponse&lt;/strong&gt;. Przykład niestandardowej klasy widoku:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class MyCustomView : IView
{
    private string _viewPhysicalPath;

    public MyCustomView(string ViewPhysicalPath)
    {
        viewPhysicalPath = ViewPhysicalPath;
    }

    public void Render(ViewContext viewContext, System.IO.TextWriter writer)
    {
        string rawcontents = File.ReadAllText(_viewPhysicalPath);
        string parsedcontents = Parse(rawcontents, viewContext.ViewData);
        writer.Write(parsedcontents);
    }

    public string Parse(string contents, ViewDataDictionary viewdata)
    {
        return Regex.Replace(contents, "\\{(.+)\\}", m =&amp;gt; GetMatch(m,viewdata));
    }

    public virtual string GetMatch(Match m, ViewDataDictionary viewdata)
    {
        if (m.Success)
        {
            string key = m.Result("$1");
            if (viewdata.ContainsKey(key))
            {
                return viewdata[key].ToString();
            }
        }
        return string.Empty;
    }
}
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Model binding&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Wiązanie modeli (ang. &lt;em&gt;model binding&lt;/em&gt;) jest narzędziem ułatwiającym komunikację jedno i dwu kierunkową pomiędzy modelami i formularzami. Czasami nie ma bezpośredniej korelacji pomiędzy widokiem i modelem. W takich wypadkach można utworzyć niestandardowy modelu wiązania. Przykład niestandardowej klasy wiązania z listą właściwości używanych w różnych modelach, które są pobierane z trzech pól formularza i mają być wiązane jako &lt;em&gt;DateTime&lt;/em&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class DropDownDateTimeBinder : DefaultModelBinder
{
    private List&amp;lt;string&amp;gt; DateTimeTypes = new List&amp;lt;string&amp;gt;{ "BirthDate",
        "StartDate", "EndDate" };

    protected override void BindProperty(ControllerContext contContext,
        ModelBindingContext bindContext, PropertyDescriptor propDesc)
    {
        if (DateTimeTypes.Contains(propDesc.Name))
        {
            if (!string.IsNullOrEmpty(
                contContext.HttpContext.Request.Form[propDesc.Name + "Year"])
            {
                DateTime dt = new DateTime(int.Parse(
                        contContext.HttpContext.Request.Form[propDesc.Name
                    + "Year"]),
                    int.Parse(contContext.HttpContext.Request.Form[propDesc.Name +
                        "Month"]),
                    int.Parse(contContext.HttpContext.Request.Form[propDesc.Name +
                        "Day"]));
                propDesc.SetValue(bindContext.Model, dt);
                return;
            }
        }
        base.BindProperty(contContext, bindContext, propDesc);
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Rejestracja klasy odbywa się w metodzie &lt;strong&gt;Application_Start&lt;/strong&gt; pliku &lt;strong&gt;Global.asax&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;ModelBinders.Binders.DefaultBinder = new DropDownDateTimeBinder();
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Zamiast nadpisania domyślnej klasy &lt;strong&gt;DefaultModelBinder&lt;/strong&gt; można utworzyć własne klasy wiązań. Klasa musi implementować &lt;strong&gt;System.Web.Mvc.IModelBinder&lt;/strong&gt; i implementować metodę &lt;strong&gt;BindModel&lt;/strong&gt;. Taką klasę również rejestrujemy w &lt;strong&gt;Application_Start&lt;/strong&gt; pliku &lt;strong&gt;Global.asax&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;ModelBinders.Binders.Add(typeof(MyNewModelBinder), new MyNewModelBinder ());
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Routing&lt;/h3&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Domyślny moduł obsługi routingu daje programiście wiele możliwości lecz czasami może zaistnieć potrzeba dodania dodatkowej funkcjonalności. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; pozwala na utworzenie własnych modułów obsługi routingu. Można albo nadpisać istniejący moduł albo całkowicie go zastąpić. Główny moduł obsługi tras jest zaimplementowany w klasie &lt;strong&gt;System.Web.Mvc.MvcRouteHandler&lt;/strong&gt;. Nadpisując klasę &lt;strong&gt;MvcRouteHandler&lt;/strong&gt; trzeba nadpisać metodę &lt;strong&gt;GetHttpHandler&lt;/strong&gt; ponieważ pozwala ona na badanie wartości i ich zmianę jeżeli to konieczne. Przykład niestandardowego modułu routingu:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public class MyCustomRouteHandler : MvcRouteHandler
{
    protected override IHttpHandler GetHttpHandler(RequestContext reqContext)
    {
        string importantValue = reqContext.HttpContext.Request.Headers.Get(
            "User-Agent");
        if (!string.IsNullOrWhiteSpace(importantValue))
        {
            reqContext.RouteData.Values["action"] = importantValue +
                reqContext.RouteData.Values["action"];
        }
        return base.GetHttpHandler(reqContext);
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Rejestracja niestandardowego modułu routingu dla poszczególnych tras odbywa się w metodzie &lt;strong&gt;MapRoute&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;routes.MapRoute(
    "Home",
    "{controller}/{action}",
    new { controller = "Home", action = "Index"
    ).RouteHandler = new MyCustomRouteHandler ();
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Jeżeli potrzebujemy całkowitego nadpisania modułu routingu to należy zaimplementować interfejs &lt;strong&gt;System.Web.Routing.IRouteHandler&lt;/strong&gt; i metodę &lt;strong&gt;GetHttpHandler&lt;/strong&gt;. Rejestracja w systemie jest trochę inna ponieważ metoda &lt;strong&gt;MapRoute&lt;/strong&gt; automatycznie mapuje na &lt;strong&gt;MvcRouteHandler&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;Route watermarkRoute = new Route("images/{name}",
    new WaterMarkRouteHandler("CodeClimber - 2011"));
routes.Add("image", watermarkRoute);
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom: 1px solid #eeeeee;"&gt;Redukcja obciążenia sieci&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Gdy pasmo jest minimalne lub zdławione, można podwyższyć dobre doświadczenia użytkownika poprzez zapewnienie, że liczba i rozmiar plików, których potrzebuje pobrać jest minimalna.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Większość nowoczesnych przeglądarek ogranicza liczbę jednoczesnych połączeń do tej samej domeny do sześciu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Istnieje kilka procesów które można uruchomić aby zmniejszyć rozmiar plików i zmniejszyć ilość plików do pobrania. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; wspiera minimalizację plików &lt;strong&gt;JavaScript&lt;/strong&gt; i &lt;strong&gt;CSS&lt;/strong&gt;. W tym procesie usuwane są komentarze, białe znaki oraz inne nieużywane i zaśmiecające plik znaki. Proces ten również zmniejsza nazwy metod i zmiennych w plikach &lt;strong&gt;JavaScript&lt;/strong&gt;. Minifikacja w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; odbywa się po przełączeniu trybu kompilacja debug na false:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;compilation debug="false" /&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Można tego również dokonać dodając wpis do metody &lt;strong&gt;RegisterBundles&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;BundleTable.EnableOptimizations = true;
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Innym procesem oferowanym w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; jest tworzenie pakietów skryptów (ang. &lt;em&gt;bundle&lt;/em&gt;). &lt;strong&gt;ASP.NET MVC bundling&lt;/strong&gt; pozwala na tworzenie jednego pliku połączonego z wielu innych plików tak aby zmniejszyć liczbę połączeń pobierających pliki. Przykład tworzenia pakietu w pliku &lt;strong&gt;BundleConfig.cs&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;bundles.Add(new ScriptBundle("~/bundles/myBundle").Include("~/Scripts/myScript1.js",
    "~/Scripts/myScript2.js",
    "~/Scripts/myScript3.js"));
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Aby odwołać sie do pakietu używamy poniższego kodu:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@BundleTable.Bundles.ResolveBundleUrl(("~/bundles/myBundle")
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Do pakietu dodawany jest &lt;em&gt;hashtag&lt;/em&gt; dzięki któremu przeglądarka wie czy ma pobrać nową wersję pliku czy też tą która jest zapisana w pamięci podręcznej.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;IIS&lt;/strong&gt; pozwala na skonfigurowanie serwera tak aby przesyłał skompresowaną treść do przeglądarek które akceptują spakowaną treść. Serwer może skompresować statyczne pliki jak &lt;strong&gt;JS&lt;/strong&gt; i &lt;strong&gt;CSS&lt;/strong&gt; jak również wszystkie inne pliki dynamiczne. Można ustawić minimalny rozmiar pliku dla którego uruchamiana będzie kompresja. Przeglądarki akceptujące spakowaną treść przesyłają nagłówek:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;Accept-Encoding: gzip, deflate
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład wysyłania pliku skompresowanego przez &lt;strong&gt;System.IO.Compression.GZipStream&lt;/strong&gt; jako &lt;strong&gt;ContentResult&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;using (FileStream oFileStream = article.LocalFile.OpenRead())
{
    using (FileStream cFileStream = File.Create(
        Guid.NewGuid().ToString() + ".gz"))
    {
        using (GZipStream compressionStream =
            new GZipStream(cFileStream, CompressionMode.Compress))
        {
            oFileStream.CopyTo(compressionStream);
            StreamReader reader = new StreamReader(compressionStream);
            results = reader.ReadToEnd();
        }
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Zwracając &lt;strong&gt;ContentResult&lt;/strong&gt; należy rozważyć dodanie typu &lt;strong&gt;MIME&lt;/strong&gt;.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Content Delivery Network (CDN)&lt;/strong&gt; pozwalają na rozprowadzanie treści przez cały szereg dostawców co daje pewne korzyści. Twój serwer musi przetworzyć mniej operacji &lt;strong&gt;GET&lt;/strong&gt; do pobrania zdjęć, skryptów itp. &lt;strong&gt;CDN&lt;/strong&gt; potrafi umieścić treść bliżej klienta co prowadzi do potencjalnego mniejszego czasu pobierania plików i wzrostu wydajności.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="height: 0; width: 0; max-height: 0; max-width: 0; overflow: hidden; font-size: 0em; padding: 0; margin: 0;"&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:42:24 Z</pubDate>
      <a10:updated>2016-08-08T19:42:24Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1131</guid>
      <link>http://smsoft.pl/blog/i-architektura-aplikacji-mvc/</link>
      <title>I. Architektura aplikacji MVC</title>
      <description>&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Podział aplikac&lt;strong&gt; ASP.NET MVC &lt;/strong&gt;&lt;span style="font-size: 1.4em;"&gt;ji na warstwy&lt;/span&gt;&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; wprowadza poziom separacji zagadnień &lt;strong&gt;SoC&lt;/strong&gt; poprzez podział aplikacji na model, widok i kontroler.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Widok (ang. &lt;em&gt;View&lt;/em&gt;) jest fragmentem widocznym przez użytkownika. Widok w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; może używać dwóch silników wyświetlania: &lt;strong&gt;Razor&lt;/strong&gt; i &lt;strong&gt;Web Forms&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Kontroler (ang. &lt;em&gt;Controller&lt;/em&gt;) parsuje żądanie &lt;em&gt;HTTP&lt;/em&gt; i wysyła komendy do modelu aby zaktualizować jego stan oraz do widoku aby odświeżyć prezentację modeli w widoku.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Model (ang. &lt;strong&gt;Model&lt;/strong&gt;) zarządza danymi i logiką biznesową.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Planując podział aplikacji trzeba brać pod uwagę skalowalność (pamięć podręczną, przetwarzanie po stronie klienta przeciw przetwarzaniu po stronie serwera oraz dostęp do danych).&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET Entity Framework&lt;/strong&gt; pozwala na trzy podejścia w tworzeniu modelu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Bezstanowa natura &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; uniemożliwia użycie niektórych funkcji &lt;strong&gt;Entity Framework&lt;/strong&gt;, dlatego najlepiej jest użyć warstwy abstrakcji dostępu do danych tworząc warstwę modelu np korzystając ze wzorca repozytorium.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Aplikacje rozproszone&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Tradycyjnym podejściem służącym do przesyłania danych jest użycie serwisów sieciowych (ang. &lt;em&gt;web services&lt;/em&gt;). W ciągu ostatnich lat używano różnych podejść do ich tworzenia. Serwisy &lt;strong&gt;ASMX&lt;/strong&gt; używające &lt;strong&gt;WSDL&lt;/strong&gt; zostały zastąpione przez &lt;strong&gt;WCF&lt;/strong&gt; używające &lt;strong&gt;SOAP&lt;/strong&gt;, które są powoli wypierane przez &lt;strong&gt;ASP.NET Web API&lt;/strong&gt; używające podejścia &lt;strong&gt;REST&lt;/strong&gt; oraz wzorców &lt;strong&gt;MVC&lt;/strong&gt; do zarządzania żądaniami &lt;em&gt;HTTP&lt;/em&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Projektowanie środowiska rozproszonego może być bardzo ciężkim zadaniem ponieważ każda część aplikacji która jest wdrożona samodzielnie musi komunikować się z innymi częściami aplikacji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Aplikacje hybrydowe są aplikacjami które są wdrożone w środowisku rozproszonym częściowo wewnątrz firmy i częściowo w chmurze poza firmą. Tworząc takie rozwiązania trzeba mieć na uwadze ryzykowną naturę komunikacji sieciowej i rozważyć koncept powtarzania wiadomości.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Projektując środowisko rozproszone ważnym punktem to rozważenia jest obsługa stanu aplikacji oraz czy aplikacja powinna obsługiwać sesję.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Rozproszone aplikacje mogą poprawić niezawodność, dostępność i skalowalność. Jednym ze sposobów na poziomie serwerowym jest użycie farm serwerów.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Cykl życia w Windows Azure&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Windows Azure&lt;/strong&gt; jest chmurą obliczeniową używana do budowania, wdrażania i zarządzania aplikacjami.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Windows Azure&lt;/strong&gt; zapewnia podejścia &lt;strong&gt;PaaS (platform as a service)&lt;/strong&gt; i &lt;strong&gt;IaaS (infrastructure as a service)&lt;/strong&gt;&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Windows Azure&lt;/strong&gt; udostępnia trzy typy rozwiązań: &lt;strong&gt;Virtual Machines&lt;/strong&gt;, &lt;strong&gt;Web Sites&lt;/strong&gt; i &lt;strong&gt;Cloud Services&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Istnieją trzy typy roli w &lt;strong&gt;Windows Azure&lt;/strong&gt;: &lt;strong&gt;Web&lt;/strong&gt;, &lt;strong&gt;Worker&lt;/strong&gt; i &lt;strong&gt;VM&lt;/strong&gt;. Rola &lt;strong&gt;Web&lt;/strong&gt; jest używana do uruchamiania &lt;strong&gt;IIS&lt;/strong&gt;, rola &lt;strong&gt;Worker&lt;/strong&gt; do aplikacji warstwy pośredniej. Rola &lt;strong&gt;VM&lt;/strong&gt; jest używana w przypadkach kiedy pozostałe nie spełniają warunków udostępniając całą maszynę wirtualną.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Ponieważ &lt;strong&gt;Windows Azure&lt;/strong&gt; jest systemem bezstanowym to żadne zmiany w systemie gdy rola jest uruchomiona nie są zapisywane do następnego uruchomienia. Dlatego programista może ustawić zestaw zadań startowych używających naarzędzia &lt;strong&gt;AppCmd.exw&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Zadania startowe w &lt;strong&gt;Windows Azure&lt;/strong&gt; są używane do wykonywania akcji przed wystartowaniem roli typu &lt;strong&gt;Web&lt;/strong&gt; lub &lt;strong&gt;Worker&lt;/strong&gt;. Pozwalają na rejestrację komponentów COM, instalację komponentów lub ustawienie kluczy rejestru.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Zadania startowe są definiowane w elemencie &lt;strong&gt;Task&lt;/strong&gt; który jest węzłem elementu &lt;strong&gt;Startup&lt;/strong&gt; w pliku &lt;strong&gt;ServiceDefinition.csdef&lt;/strong&gt;. Typowym zadaniem jest aplikacja konsolowa lub plik wsadowy który startuje skrypty &lt;em&gt;Windows PowerShell&lt;/em&gt;. Zadanie startowe jest wykonywane za każdym razem gdy rola zostaje ponownie uruchomiona. Zadania pozwalają uruchomić procesy i aplikacje wspomagające główną aplikację.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Po wykonaniu zadania wywoływana jest metoda &lt;strong&gt;OnStart&lt;/strong&gt; którą można nadpisać aby zaimplementować własną funkcjonalność. metoda ta musi zwracać &lt;em&gt;true&lt;/em&gt; aby uruchomienie nie zatrzymało się błędem.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Po wykonaniu &lt;strong&gt;OnStart&lt;/strong&gt; uruchamiana jest metoda &lt;strong&gt;Run&lt;/strong&gt;, która nie zwraca wyniku. Można ją nadpisać i uruchamiać w niej aplikacje równolegle.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Po wyłączeniu wywoływana jest metoda &lt;strong&gt;OnStop&lt;/strong&gt; która również nie zwraca żadnego wyniku. Jest używana do zamknięcia i czyszczenia uruchomionych procesów.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Zarządzanie stanem aplikacji&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Zarządzanie stanem może być ważną częścią aplikacji. W aplikacjach www jest skomplikowane ponieważ z definicji protokół &lt;em&gt;HTTP&lt;/em&gt; jest bezstanowy. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; oferuje wiele dróg implementacji stanu. Kiedy wybieramy jeden z nich musimy wziąć pod uwagę czynniki takie jak: miejsce przechowywania i używania stanu (klient czy serwer), ilość danych do przechowania oraz opóźnienia.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;W &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; stan aplikacji może być przechowywany w: &lt;strong&gt;Cache&lt;/strong&gt;, &lt;strong&gt;Session&lt;/strong&gt;, &lt;strong&gt;Cookies&lt;/strong&gt;, &lt;strong&gt;QueryString&lt;/strong&gt;, &lt;strong&gt;Context.Items&lt;/strong&gt; i &lt;strong&gt;Profile&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Obiekt &lt;strong&gt;Cache&lt;/strong&gt; zapewnia szerszy zakres niż inne rodzaje ponieważ jego dane są dostępne dla wszystkich klas aplikacji. Obiekt &lt;strong&gt;Cache&lt;/strong&gt; umożliwia przechowywanie par klucz-wartość dostępnych dla każdego użytkownika lub stronę w domenie aplikacji. Jest przetwarzany w wewnętrznym procesie dlatego jest dostępny na indywidualnym serwerze. W scenariuszach wieloserwerowych trzeba zapewnić aby każdy serwer miał własną kopię obiektu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Najbardziej powszechnym sposobem zarządzania stanem jest sesja. Sesja może być przechowywana w bazie &lt;em&gt;SQL Server&lt;/em&gt;, na osobnym serwerze lub w pamięci serwera &lt;em&gt;IIS&lt;/em&gt;. Sesję można skonfigurować tak aby przekazywała &lt;strong&gt;session ID&lt;/strong&gt; w &lt;strong&gt;cookie&lt;/strong&gt; lub &lt;strong&gt;query string&lt;/strong&gt;. Implementując sesję można użyć domyślnego magazynu przychodzącego z &lt;strong&gt;ASP.NET&lt;/strong&gt; lub utworzyć własny dziedzicząc z klasy &lt;strong&gt;SessionStateStoreProviderBase&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Cookies&lt;/strong&gt; są małymi porcjami informacji (do 4 KB) przechowywanymi po stronie klienta które mogą być utrwalane w sesji. Są przypisane do konkretnej domeny lub subdomeny i przesyłane do serwera z każdym żądaniem. &lt;strong&gt;Cookies&lt;/strong&gt; można odczytać używając &lt;strong&gt;HttpContext.Request.Cookies&lt;/strong&gt; i zapisać używając &lt;strong&gt;HttpContext.Response.Cookies&lt;/strong&gt;. &lt;strong&gt;Cookie&lt;/strong&gt; może posiadać również datę wygaśnięcia.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Query string&lt;/strong&gt; jest również miejscem gdzie można wstawić pewną ograniczoną ilość informacji (długość żądania &lt;em&gt;URL&lt;/em&gt; jest ograniczona),które mogą być przesłane do serwera i z powrotem dla konkretnego użytkownika. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; zapewnia łatwy dostęp do &lt;strong&gt;query string&lt;/strong&gt; poprzez &lt;strong&gt;HttpContext.Request.QueryString[“attributeName”]&lt;/strong&gt; po stronie serwera i &lt;strong&gt;window.location.href&lt;/strong&gt; po stronie klienta.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Context.Items&lt;/strong&gt; zawiera informacje dostępne dla jednego żądania. Zwykle używa się go do dodania informacji do żądania w komunikacji między modułami &lt;em&gt;HTTP&lt;/em&gt;, np. informacje o uwierzytelnieniu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Profile&lt;/strong&gt; jest przechowywane w bazie danych dla nazwy użytkownika i może być dostępne używając &lt;strong&gt;HttpContext.Profile[“miscellaneousData”]&lt;/strong&gt;. &lt;strong&gt;Profile&lt;/strong&gt; jest częścią dostawcy &lt;strong&gt;Membership and Roles&lt;/strong&gt; i trzeba skonfigurować dostawcę w pliku konfiguracyjnym oraz używać &lt;strong&gt;ASP.NET membership&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Istnieje również możliwość przechowywania informacji o stanie po stronie klienta np używając &lt;strong&gt;HTML5 Web Storage API&lt;/strong&gt;. Niestety &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; nie posiada domyślnych narzędzi do pracy z informacjami przechowywanymi po stronie klienta poza biblioteką &lt;strong&gt;jQuery&lt;/strong&gt;. &lt;strong&gt;HTML5 Web Storage&lt;/strong&gt; pozwala na wybór pomiędzy &lt;strong&gt;sessionStorage&lt;/strong&gt; a &lt;strong&gt;localStorage&lt;/strong&gt;. Zasięg &lt;strong&gt;sessionStorage&lt;/strong&gt; pozwala na dostęp do zasobów dla stron w tej samej domenie &lt;em&gt;URL&lt;/em&gt;. Obiekty w &lt;strong&gt;sessionStorage&lt;/strong&gt; są przechowywane do czasu zamknięcia okna. Zasięg &lt;strong&gt;localStorage&lt;/strong&gt; rozszerza &lt;strong&gt;sessionStorage&lt;/strong&gt; i pozwala na przechowywanie obiektów poza zasięg życia okna komunikującego się z tym samym &lt;em&gt;URL&lt;/em&gt;. &lt;strong&gt;HTML5 Web Storage API&lt;/strong&gt; posiada również zdarzenia obsługujące zmiany w magazynie danych.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Skalowalność jest głównym problemem przy określaniu, jak najlepiej zarządzać stanem. Projektowanie skalowalnej architektury odrzuca automatycznie pewne dostępne rozwiązania jak np. proces w serwerze przechowujący stan ponieważ serwer może nie mieć dostępu do procesu innego serwera w klastrze.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; wspiera również protokoły bezstanowe pomocne przy skalowalności. Mechanizmy których można użyć przy obsłudze bezstanowej aplikacji to utworzenie identyfikatora przy pierwszym żądaniu użytkownika i przesyłanie go z każdym następnym żądaniem, użycie ukrytego pola przekazującego dane między żądaniami, dodanie funkcjonalności w kodzie JavaScript po stronie klienta obsługującej &lt;strong&gt;HTML5 Web Storage&lt;/strong&gt; i wysyłającej do serwera potrzebne informacje, dodanie unikalnego fragmentu do &lt;strong&gt;query string&lt;/strong&gt; lub adresu &lt;strong&gt;URL&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład konfiguracji sesji &lt;strong&gt;InProc&lt;/strong&gt; w pliku &lt;strong&gt;Web.config&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;&amp;lt;system.web&amp;gt;
    &amp;lt;sessionState mode="InProc" cookieless="false" timeout="20" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" stateConnectionString="tcpip=127.0.0.1:42424"
/&amp;gt;
&amp;lt;/system.web&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład konfiguracji sesji &lt;strong&gt;StateServer&lt;/strong&gt; w pliku &lt;strong&gt;Web.config&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;&amp;lt;system.web&amp;gt;
    &amp;lt;sessionState mode="StateServer" stateConnectionString="192.168.1.103:42424" /&amp;gt;
&amp;lt;/system.web&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład konfiguracji &lt;strong&gt;ASP.NET Membership&lt;/strong&gt; w pliku &lt;strong&gt;Web.config&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;&amp;lt;profile defaultprovider="DefaultProfileProvider" inherit="MyApplication.Models.CustomProfile"/&amp;gt;
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Projektowanie strategii buforowania&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;&lt;strong&gt;Caching&lt;/strong&gt; jest strategią pomagającą poprawić wydajność. Polega na przechowywaniu często uzywanych danych w pamięci o szybkim czasie dostępu.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Page output caching&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Page output caching&lt;/strong&gt; jest strategią dzieloną pomiędzy klientów i serwery. typy buforowania stron zawierają pełne i częściowe buforowanie strony. Przeglądarka może buforować każde żądanie &lt;strong&gt;HTTP GET&lt;/strong&gt; przez zdefiniowany okres czasu. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; pozwala na ustawienie czasu przez użycie filtru:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;[OutputCache(Duration=120, VaryByParam="Name", Location="ServerAndClient")]
Public ActionResult Index()
{
    Return View("Index",myData);
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Niestety &lt;strong&gt;OutputCache&lt;/strong&gt; działa dobrze tylko do buforowania całych stron.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Donut caching&lt;/strong&gt; (buforowanie pączkowe) i &lt;strong&gt;donut hole caching&lt;/strong&gt; są typami częściowego buforowania stron. Pierwsze buforuje większość strony umożliwiając na część zawartości dynamicznej. Drugie pozwala na większość treści dynamicznej i część buforowanej. &lt;strong&gt;Razor&lt;/strong&gt; nie obsługuje bezpośrednio &lt;strong&gt;Donut caching&lt;/strong&gt; ale można użyć &lt;strong&gt;Substitution API&lt;/strong&gt; i utworzyć helper &lt;em&gt;MVC&lt;/em&gt;. &lt;strong&gt;Donut hole caching&lt;/strong&gt; jest obsługiwane przez podzielenie fragmentów strony na różne akcje i użycie widoków częściowych które są buforowane np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;[ChildActionOnly] [OutputCache(Duration=60)]
public ActionResult ProductsChildAction()
{
    // Fetch products from the database and
    // pass it to the child view via its ViewBag
    ViewBag.Products = Model.GetProducts();
    return View();
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;można również dodać atrybut buforowania do całego kontrolera.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Windows AppFabric&lt;/strong&gt; jest przykładem narzędzia tworzącego zawartość buforowaną podzieloną pomiędzy wiele serwerów w farmie. jest to zestaw serwisów zbudowany na &lt;strong&gt;Windows server&lt;/strong&gt; które zarządzają buforowaniem rozproszonym. Może również zarządzać sesją w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Data caching&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Data caching&lt;/strong&gt; jest techniką po stronie serwera pozwalającą na wstawienie pośredniego bufora pomiędzy logikę biznesową i bazę danych. pozwala na ponowne użycie danych bez odczytu bezpośrednio z bazy danych do czasu, aż dane są nieaktualne lub ich czas życia wygaśnie.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Można użyć &lt;strong&gt;.NET 4 Caching Framework&lt;/strong&gt;. Domyślna implementacja używa &lt;strong&gt;ObjectCache&lt;/strong&gt; i &lt;strong&gt;MemoryCache&lt;/strong&gt;. Generalnie buforowanie polega na utworzeniu implementacji interfejsu &lt;strong&gt;ICacheProvider&lt;/strong&gt; użytej jako warstwa pośrednicząca pomiędzy logiką a dostępem do danych.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Application caching&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Application caching&lt;/strong&gt; jest właściwością &lt;strong&gt;HTML 5&lt;/strong&gt; która pozwala na tworzenie manifestu buforowania który opisuje ustawienia dla całej strony lub aplikacji i daje dostęp do pamięci podręcznej przeglądarki.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Dostęp dla programistów z poziomu &lt;strong&gt;Application Cache API (AppCache)&lt;/strong&gt; Przykład manifestu:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;# Cached entries.
CACHE:
/favicon.ico
default.aspx
site.css
images/logo.jpg
scripts/application.js
# Resources that are "always" fetched from the server.
NETWORK:
login.asmx
FALLBACK:
button.png offline-button.png
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Sekcja &lt;strong&gt;CACHE&lt;/strong&gt; opisuje zasoby które powinny być buforowane. Sekcja &lt;strong&gt;NETWORK&lt;/strong&gt; opisuje zasoby które nie powinny być buforowane. Sekcja &lt;strong&gt;FALLBACK&lt;/strong&gt; definiuje zasoby które powinny być zwrócone jeżeli zasoby nie zostaną odnalezione.&lt;/p&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Definicja referencji do manifestu powinna być zapisana w tagu &lt;strong&gt;HTML&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;&amp;lt;html manifest="site.manifest"&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Manifest musi mieć ustawiony &lt;strong&gt;MIME-type&lt;/strong&gt; o wartości &lt;strong&gt;“text/cache-manifest”&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;HTTP caching&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;HTTP caching&lt;/strong&gt; jest mechanizmem buforowania wbudowanym w protokół &lt;strong&gt;HTTP&lt;/strong&gt; który obsługuje własną wersję wyliczenia wygaśnięcia i używa jej do określenia odpowiedzi która ma zostać wysłana do klienta.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Implementacja WebSocket&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;HTTP polling&lt;/strong&gt; jest metodą &lt;em&gt;JavaScript&lt;/em&gt; służącą do odpytywania serwera w regularnych odstępach czasu o nowe informacje o których powinien wiedzieć klient. Niestety nie jest to wydajna metoda ale działa w każdej przeglądarce wspierającej &lt;em&gt;JavaScript&lt;/em&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;HTTP long polling&lt;/strong&gt; jest sposobem w którym ustanawia się długowieczne połączenie do serwera w celu monitorowania zmian. Połączenie zostaje utrzymane do czasu otrzymania wiadomości lub upływu określonego czasu po czym znowy zostaje ustanowione.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;WebSockets&lt;/strong&gt; jest sposobem zapewnienia dwustronnej komunikacji pomiędzy serwerem a klientem. Klient łączy się przez &lt;strong&gt;HTTP&lt;/strong&gt; i wysyła żądanie aktualizacji do serwera, który ustanawia połączenie &lt;strong&gt;WebSockets&lt;/strong&gt;. Trzeba zaimplementować komunikację po jednej i drugiej stronie aby współpracować z &lt;strong&gt;WebSockets&lt;/strong&gt;. Kiedy tego dokonamy to każda komenda jest obsługiwana jak zdarzenie zgłaszane kiedy wiadomość jest otrzymywana.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;WebSockets&lt;/strong&gt; może być użyte do długotrwałej dwustronnej komunikacji. Nie zawsze jest najlepszym rozwiązaniem, szczególnie kiedy klientem jest starsza przeglądarka która nie wspiera &lt;strong&gt;HTML 5&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;WebSockets&lt;/strong&gt; wymaga &lt;strong&gt;ASP.NET 4.5&lt;/strong&gt; i &lt;strong&gt;IIS 8&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład kodu &lt;em&gt;jQuery&lt;/em&gt; ustanawiającego połączenie &lt;strong&gt;WebSocket&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;var socket;
$(document).ready(function () {
    socket = new WebSocket("ws://localhost:1046/socket/handle");
    socket.addEventListener("open", function (evnt) {
        $("#display").append('connection');}, false);
    socket.addEventListener("message", function (evnt) {
        $("#display ").append(evnt.data);}, false);
    socket.addEventListener("error", function (evnt) {
        $("#display ").append('unexpected error.');}, false);
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład połączenie w &lt;strong&gt;ASP.NET MVC&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;public async Task MyWebSocket(AspNetWebSocketContext context)
{
    while (true)
    {
        ArraySegment&amp;lt;byte&amp;gt; arraySegment = new ArraySegment&amp;lt;byte&amp;gt;(new byte[1024]);
        // open the result. This is waiting asynchronously
        WebSocketReceiveResult socketResult =
            await context.WebSocket.ReceiveAsync(arraySegment,
            CancellationToken.None);
        // return the message to the client if the socket is still open
        if (context.WebSocket.State == WebSocketState.Open)
        {
            string message = Encoding.UTF8.GetString(arraySegment.Array, 0,
                socketResult.Count);
            userMessage = "Your message: " + message + " at " +
                DateTime.Now.ToString();
            arraySegment = new
                ArraySegment&amp;lt;byte&amp;gt;(Encoding.UTF8.GetBytes(message));
                // Asynchronously send a message to the client
            await context.WebSocket.SendAsync(arraySegment,
                WebSocketMessageType.Text,
                true, CancellationToken.None);
        }
        else { break; }
        }
}
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;HTTP modules and handlers&lt;/h2&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Umożliwiają programiście na bezpośrednią interakcję z żądaniami &lt;strong&gt;HTTP&lt;/strong&gt;. Kiedy żądanie startuje to jest przetwarzane przez wiele modułów &lt;strong&gt;HTTP modules&lt;/strong&gt;, takich jak sesja i moduł uwierzytelnienia. Różniej żądanie jest przetwarzane przez jeden &lt;strong&gt;HTTP handler&lt;/strong&gt; zanim wróci z powrotem przez stos żądania żeby ponownie być przetworzonym przez moduły.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Moduły pasują do przetwarzania w drodze do handlera i w drodze powrotnej od handlera. Moduł synchroniczny posiada metodę &lt;strong&gt;Init&lt;/strong&gt; która umożliwia ustawienie obsługi jednego ze zdarzeń załączonych do żądania.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Moduł asynchroniczny jest trudniejszy w obsłudze ale z &lt;strong&gt;async&lt;/strong&gt;, &lt;strong&gt;await&lt;/strong&gt; i &lt;strong&gt;Task&lt;/strong&gt; można utworzyć moduł który potrafi obsłużyć długotrwałe zadanie bez zatrzymywania procesu.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Moduły pozwalają na przechwycenie, dzielenie i modyfikację każdego żądania.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Utworzenie modułu wymaga implementacji interfejsu &lt;strong&gt;System.Web.IHttpModule&lt;/strong&gt; który ma dwie metody &lt;strong&gt;void Init(HttpApplication)&lt;/strong&gt; i &lt;strong&gt;Dispose&lt;/strong&gt;. &lt;strong&gt;System.Web.HttpApplication&lt;/strong&gt; posiada zdefiniowane 22 zdarzenia które mogą być subskrybowane w metodzie &lt;strong&gt;Init&lt;/strong&gt; i pozwalają modułowi na pracę w różnych stadiach obsługi żądania.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Plik &lt;strong&gt;Web.config&lt;/strong&gt; posiada sekcję odpowiedzialną za konfigurację modułu HTTP aplikacji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Handlery są celem żądań i wysyłają żądania do pojedynczego URL. Handlery mogą być synchroniczne i asynchroniczne w zależności od klasy z której dziedziczą.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Handler musi implementować interfejs &lt;strong&gt;IHttpHandler&lt;/strong&gt; z metodą &lt;strong&gt;ProcessRequest(HttpContext)&lt;/strong&gt; i właściwością &lt;strong&gt;IsReusable&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wybór pomiędzy modułem a handlerem zależy od miejsca w którym trzeba zmienić funkcjonalność. Jeżeli musisz obsłużyć specyficzny adres URL to prawdopodobnie potrzebujesz utworzyć handler. Jeżeli chcesz zadziałać kiedy coś się wydarzy w czasie przetwarzania to powinieneś użyć modułu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład asynchronicznego modułu:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;private async Task ScrapePage(object caller, EventArgs e)
{
    WebClient webClient = new WebClient();
    var downloadresult = await webClient.DownloadStringTaskAsync("http://www.msn.com");
}
public void Init(HttpApplication context)
{
    EventHandlerTaskAsyncHelper helper =
        new EventHandlerTaskAsyncHelper(ScrapePage);
    context.AddOnPostAuthorizeRequestAsync(
        helper.BeginEventHandler, helper.EndEventHandler);
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład asynchronicznego handlera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; margin: 1.2em 0px;"&gt;public class NewAsyncHandler : HttpTaskAsyncHandler
{
    public override async Task ProcessRequestAsync(HttpContext context)
    {
        WebClient webClient = new WebClient();
        var downloadresult = await
        webClient.DownloadStringTaskAsync("http://www.msn.com");
    }
}
&lt;/pre&gt;
&lt;div style="height: 0; width: 0; max-height: 0; overflow: hidden; font-size: 0em; padding: 0; margin: 0;"&gt;&lt;/div&gt;</description>
      <pubDate>Sun, 31 Jul 2016 13:05:50 Z</pubDate>
      <a10:updated>2016-07-31T13:05:50Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1130</guid>
      <link>http://smsoft.pl/blog/ii-projektowanie-interfejsu-uzytkownika/</link>
      <title>II. Projektowanie interfejsu użytkownika</title>
      <description>&lt;div&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Interfejs użytkownika w aplikacjach web&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Język &lt;strong&gt;HTML&lt;/strong&gt; pozwala opisać strukturę informacji zawartych wewnątrz strony internetowej. &lt;strong&gt;CSS&lt;/strong&gt; wprowadza dodatkową kontrolę nad wyglądem i prezentacją strony internetowej. Kombinacja &lt;strong&gt;HTML&lt;/strong&gt; i &lt;strong&gt;CSS&lt;/strong&gt; pozwala różnym stronom wyglądać inaczej od pozostałych pomimo użycia tych samych konstrukcji.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Podstawową funkcją &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; jest dostarczanie informacji do użytkownika serwisu. &lt;strong&gt;HTML&lt;/strong&gt; i &lt;strong&gt;CSS&lt;/strong&gt; pozwalają na formatowanie tych informacji w atrakcyjny wizualnie sposób.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Dynamiczna zawartość strony jest głównym powodem do korzystania z &lt;strong&gt;ASP.NET MVC&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Używając silnika wyświetlania &lt;strong&gt;Razor&lt;/strong&gt;, plik &lt;strong&gt;Views\Shared_Layout.cshtml&lt;/strong&gt; zawiera główny szablon aplikacji a w tym odnośnik do plików ze stylami &lt;strong&gt;CSS&lt;/strong&gt;, podstawowe elementy &lt;em&gt;UI&lt;/em&gt; jak na menu, nagłówki i stopkę.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Silnik wyświetlania &lt;strong&gt;ASPX&lt;/strong&gt; używa pliku &lt;strong&gt;Views\Shared\Site.Master&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Plik szablonu bazowego dziedziczy z &lt;strong&gt;System.Web.Mvc.ViewMasterPage&lt;/strong&gt; niezależnie od silnika wyświetlania.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %&amp;gt;
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Helpery&lt;/strong&gt; są konstrukcjami kodu &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; tworzącymi kod &lt;strong&gt;HTML&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Helper wyświetlający style css w silniku &lt;strong&gt;Razor&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@Styles.Render("~/Content/css")
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład szablonu w pliku &lt;strong&gt;Views\Shared_Layout.cshtml&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;title&amp;gt;@ViewBag.Title - My ASP.NET MVC Application&amp;lt;/title&amp;gt;
    &amp;lt;link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width" /&amp;gt;
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;header&amp;gt;
        &amp;lt;div class="content-wrapper"&amp;gt;
            &amp;lt;div class="float-left"&amp;gt;
                &amp;lt;p class="site-title"&amp;gt;
                    @Html.ActionLink("your logo here", "Index", "Home")
                &amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="float-right"&amp;gt;
                &amp;lt;section id="login"&amp;gt;
                    @Html.Partial("_LoginPartial")
                &amp;lt;/section&amp;gt;
                &amp;lt;nav&amp;gt;
                    &amp;lt;ul id="menu"&amp;gt;
                        &amp;lt;li&amp;gt;@Html.ActionLink("Home", "Index", "Home")&amp;lt;/li&amp;gt;
                        &amp;lt;li&amp;gt;@Html.ActionLink("About", "About", "Home")&amp;lt;/li&amp;gt;
                        &amp;lt;li&amp;gt;@Html.ActionLink("Contact", "Contact", "Home")&amp;lt;/li&amp;gt;
                    &amp;lt;/ul&amp;gt;
                &amp;lt;/nav&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/header&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Nowe tagi &lt;strong&gt;HTML 5&lt;/strong&gt;&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- sekcja strony zawierająca niezależną treść.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- treść powiązana do otaczającej treści.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- podpis ilustracji.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- ilustracja.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- stopka dokumentu lub sekcji.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- nagłówek dokumentu lub sekcji.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- sekcja z odnośnikami.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;
&lt;div&gt;- grupa treści które są ze sobą powiązane.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Projektowanie zachowania UI&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Walidacja po stronie klienta jest istotną właściwością &lt;strong&gt;JavaScript&lt;/strong&gt; i &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; dzięki której eliminowane są przesyłania danych pomiędzy klientem a serwerem poprzez sprawdzenie po stronie klienta czy dane wprowadzone do formularza są poprawne. Zasady walidacji &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; są zbudowane w oparciu o adnotacje. Przykład klasy z adnotacjami służącymi do walidacji:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;namespace ArticleApp.Models {
    public class Article {
        public int ID { get; set; }
        [Required] [StringLength(50,MinimumLength=5)]
        public string Title { get; set; }
        [RegularExpression[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}")]
        AuthorEmail { get; set;}
        [DataType(DataType.Date)]
        [Range(300, 3000)]
        public int NumberOfAuthors { get; set; }
        [Required]
        public DateTime CreateDate { get; set; }
        [Required]
        public string Description { get; set; }
        [Range(1, 250)]
        [DataType(DataType.Currency)]
        [Required]
        public decimal Price { get; set; } 
    }
    public class ArticleDBContext : DbContext
    {
        public DbSet&amp;lt;Article&amp;gt; Articles { get; set; }
    }
}
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład widoku dodawania nowego artykułu:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@model MvcApplication1.Models.Article @{ ViewBag.Title = "Create"; }
&amp;lt;h2&amp;gt;Create&amp;lt;/h2&amp;gt; @using (Html.BeginForm()) { @Html.ValidationSummary(true)
&amp;lt;fieldset&amp;gt;
    &amp;lt;legend&amp;gt;Articles&amp;lt;/legend&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.Title)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model.Title) @Html.ValidationMessageFor(model =&amp;gt; model.Title)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.CreateDate)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model.CreateDate) @Html.ValidationMessageFor(model =&amp;gt; model.CreateDate)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.Description)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model.Description) @Html.ValidationMessageFor(model =&amp;gt; model.Description)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.Price)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model.Price) @Html.ValidationMessageFor(model =&amp;gt; model.Price)
    &amp;lt;/div&amp;gt;
    &amp;lt;p&amp;gt;
        &amp;lt;input type="submit" value="Create" /&amp;gt;
    &amp;lt;/p&amp;gt;
&amp;lt;/fieldset&amp;gt;
}
&amp;lt;div&amp;gt;
    @Html.ActionLink("Back to List", "Index")
&amp;lt;/div&amp;gt;
@section Scripts { @Scripts.Render("~/bundles/jqueryval") }
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Sprawdzenie poprawności modelu po stronie akcji kontrolera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[HttpPost]
public ActionResult Create(Article article)
{
    if (ModelState.IsValid)
    {
        db.Articles.Add(article);
        db.SaveChanges();
        return RedirectToAction("Index");
    }
    return View(article);
}
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Aby &lt;em&gt;UI&lt;/em&gt; mogło wykonać akcję walidacji po stronie serwera należy dodać atrybut &lt;strong&gt;System.Web.Mvc.RemoteAttribute&lt;/strong&gt; do walidacji w modelu. Atrybut &lt;strong&gt;Remote&lt;/strong&gt; akceptuje nazwę kontrolera i akcji które mają być wywołane. Walidacja po stronie serwera wymaga też dodatkowej konfiguracji.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Wpis wymagany w konfiguracji aby można było wykonać walidację po stronie serwera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;appSettings&amp;gt;
    &amp;lt;add key="ClientValidationEnabled" value="true" /&amp;gt;
    &amp;lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&amp;gt;
&amp;lt;/appSettings&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład modelu z walidacją po stronie serwera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;[Required]
[StringLength(6, MinimumLength = 3)]
[Remote("IsUserAvailable", "Validation")]
[RegularExpression(@"(\S)+", ErrorMessage = "White space is not allowed.")]
[Editable(true)]
public string UserName { get; set; }
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład walidacji po stronie serwera:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;public JsonResult IsUserAvailable(string username)
{
    if (!WebSecurity.UserExists(username))
    {
        return Json(true, JsonRequestBehavior.AllowGet);
    }
    string suggestedUID = String.Format(CultureInfo.InvariantCulture,
        "{0} is not available.", username);
    for (int i = 1; i &amp;lt; 100; i++)
    {
        string altCandidate = username + i.ToString();
        if (!WebSecurity.UserExists(altCandidate))
        {
            suggestedUID = String.Format(CultureInfo.InvariantCulture,
                "{0} is not available. Try {1}.", username, altCandidate);
            break;
        }
    }
    return Json(suggestedUID, JsonRequestBehavior.AllowGet);
}
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Biblioteki &lt;strong&gt;JavaScript&lt;/strong&gt; mogą być pomocne przy projektowaniu &lt;em&gt;UI&lt;/em&gt;. Przykładowo dzięki &lt;strong&gt;jQuery&lt;/strong&gt; można manipulować drzewem &lt;strong&gt;DOM&lt;/strong&gt;, tworzyć efekty i animacje dzięki czemu strona staje się bardziej interaktywna.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;JavaScript&lt;/strong&gt; jest interpretowanym językiem skryptowym bazującym na prototypowniu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład kodu &lt;strong&gt;JavaScript&lt;/strong&gt; używającego prototypów:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;var Contact = function(pageTitle) {
    this.pageTitle = pageTitle;
    this.bindEvents(); // binding events as soon as the object is instantiated
    this.additionalEvents(); // additional events such as DOM manipulation etc
};
var Contact.prototype.bindEvents = function() {
    $('ul.menu').on('click', 'li.email, $.proxy(this.toggleEmail, this));
};
var Contact.prototype.toggleEmail = function(e) {
    //Toggle the email feature on the page
};
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;AJAX&lt;/strong&gt; służy do asynchronicznej aktualizacji części strony bez całkowitego jej przeładowania. &lt;strong&gt;ASP.NET MVC&lt;/strong&gt; posiada przestrzeń nazw &lt;strong&gt;System.Web.MVC.Ajax&lt;/strong&gt; która zawiera zestaw rozszerzeń wspierających użycie &lt;strong&gt;AJAX&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład formularza używającego &lt;strong&gt;AJAX&lt;/strong&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@model MvcApplication1.Models.Article @{ ViewBag.Title = "Create"; }
&amp;lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /&amp;gt;
&amp;lt;script src="http://code.jquery.com/jquery-1.8.3.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;link rel="stylesheet" href="/resources/demos/style.css" /&amp;gt;
&amp;lt;script&amp;gt;
    $(function () {
        $(".ReleaseDate").datepicker();
    });
&amp;lt;/script&amp;gt;
&amp;lt;h2&amp;gt;Create&amp;lt;/h2&amp;gt; @using (Ajax.BeginForm("PerformAction", new AjaxOptions { OnSuccess = "OnSuccess", OnFailure = "OnFailure" })) {
&amp;lt;fieldset&amp;gt;
    &amp;lt;legend&amp;gt;Article&amp;lt;/legend&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.Title)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model.Title) @Html.ValidationMessageFor(model =&amp;gt; model.Title)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.CreateDate)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model. CreateDate) @Html.ValidationMessageFor(model =&amp;gt; model. CreateDate)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.Description)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model. Description) @Html.ValidationMessageFor(model =&amp;gt; model. Description)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-label"&amp;gt;
        @Html.LabelFor(model =&amp;gt; model.Price)
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.EditorFor(model =&amp;gt; model.Price) @Html.ValidationMessageFor(model =&amp;gt; model.Price)
    &amp;lt;/div&amp;gt;
    &amp;lt;p&amp;gt;
        &amp;lt;input type="submit" value="Create" /&amp;gt;
    &amp;lt;/p&amp;gt;
&amp;lt;/fieldset&amp;gt;
}
&amp;lt;p id="errorMessage" /&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
    function OnSuccess(response) {
        //do something
    }

    function OnFailure(response) {
        //show failure
        document.getElementById('errorMessage').innerHTML = 'THERE WAS AN ERROR';
    }
&amp;lt;/script&amp;gt;
&amp;lt;div&amp;gt;
    @Html.ActionLink("Back to List", "Index")
&amp;lt;/div&amp;gt;
@section Scripts { @Scripts.Render("~/bundles/jqueryval") }
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Komponowanie szablonu UI&lt;/h2&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Partial view&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Widok częściowy jest sposobem na użycie tej samej funkcjonalności na wielu stronach. Pozwala na zawieranie pod-widoku w wielu miejscach aplikacji. Zwykle przechowuje się je w folderze &lt;strong&gt;Views/Shared&lt;/strong&gt;&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Widok częściowy można utworzyć poprzez menu kontekstowe na folderze z widokami i wybranie opcji &lt;strong&gt;Add View&lt;/strong&gt; oraz zaznaczenie &lt;strong&gt;Create as a partial view&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Użycie modelu w widoku częściowym wymaga dodania jego deklaracji:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@model ApplicationName.Models.ModelName
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Wstawienie widoku do aplikacji odbywa się za pomocą składni &lt;strong&gt;@Html.Partial&lt;/strong&gt; np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;section id="login"&amp;gt;
    @Html.Partial("_LoginPartial")
&amp;lt;/section&amp;gt;
&lt;/pre&gt;
&lt;h3 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;"&gt;Razor&lt;/h3&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Silnik &lt;strong&gt;Razor&lt;/strong&gt; pozwala na tworzenie szablonów które mogą być używane wielokrotnie. Szablony są przypisywane według typu obiektu, mogą służyć do wyświetlania (DisplayTemplates) lub edycji (EditTemplates). Szablony są przechowywane w &lt;strong&gt;~Views/Shared/EditorTemplates&lt;/strong&gt; i wywoływane przez &lt;strong&gt;@Html.EditorFor&lt;/strong&gt; i &lt;strong&gt;@Html.DisplayFor&lt;/strong&gt;, np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;@Html..EditorFor(model=&amp;gt;model.Article)
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;Razor&lt;/strong&gt; tag &lt;strong&gt;@RenderBody()&lt;/strong&gt; wstawia różne widoki do aplikacji z użyciem tagu
&lt;div&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Widoki i widoki częściowe powinny być używane wielokrotnie wszędzie gdzie jest to możliwe. Jeżeli widoki lub widoki częściowe używają tego samego modelu i kontrolera to można sprawdzić poprawność modelu za pomocą adnotacji i helperów HTML. W innym przypadku trzeba obsłużyć sprawdzanie poprawności samemu używając np &lt;strong&gt;AJAX&lt;/strong&gt; do sprawdzenia poprawności po stronie klienta lub modyfikując kontroler i modele do tego zadania.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Szablony &lt;strong&gt;master&lt;/strong&gt; lub &lt;strong&gt;layout&lt;/strong&gt; mogą być przełączane w locie z wykorzystaniem kodu. ponieważ szablony zawierają zwykle informacje o bibliotekach &lt;strong&gt;JavaScript&lt;/strong&gt; i stylach &lt;strong&gt;CSS&lt;/strong&gt; to ich przełączenie może zmienić znacząco &lt;em&gt;UI&lt;/em&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Biblioteka &lt;strong&gt;Modernizr.js&lt;/strong&gt; ułatwia pisanie warunkowego kodu &lt;strong&gt;JavaScript&lt;/strong&gt; i &lt;strong&gt;CSS&lt;/strong&gt; w celu ustalenia, czy przeglądarka obsługuje funkcję, zwłaszcza HTML5.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład kompletnego szablonu tworzonego przez &lt;em&gt;Visual Studio&lt;/em&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;@ViewBag.Title - My ASP.NET Application&amp;lt;/title&amp;gt;
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="navbar navbar-inverse navbar-fixed-top"&amp;gt;
        &amp;lt;div class="container"&amp;gt;
            &amp;lt;div class="navbar-header"&amp;gt;
                &amp;lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"&amp;gt;
                    &amp;lt;span class="icon-bar"&amp;gt;&amp;lt;/span&amp;gt;
                    &amp;lt;span class="icon-bar"&amp;gt;&amp;lt;/span&amp;gt;
                    &amp;lt;span class="icon-bar"&amp;gt;&amp;lt;/span&amp;gt;
                &amp;lt;/button&amp;gt;
                @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="navbar-collapse collapse"&amp;gt;
                &amp;lt;ul class="nav navbar-nav"&amp;gt;
                    &amp;lt;li&amp;gt;@Html.ActionLink("Home", "Index", "Home")&amp;lt;/li&amp;gt;
                    &amp;lt;li&amp;gt;@Html.ActionLink("About", "About", "Home")&amp;lt;/li&amp;gt;
                    &amp;lt;li&amp;gt;@Html.ActionLink("Contact", "Contact", "Home")&amp;lt;/li&amp;gt;
                &amp;lt;/ul&amp;gt;
                @Html.Partial("_LoginPartial")
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="container body-content"&amp;gt;
        @RenderBody()
        &amp;lt;hr /&amp;gt;
        &amp;lt;footer&amp;gt;
            &amp;lt;p&amp;gt;&amp;amp;copy; @DateTime.Now.Year - My ASP.NET Application&amp;lt;/p&amp;gt;
        &amp;lt;/footer&amp;gt;
    &amp;lt;/div&amp;gt;

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Wykrywanie cech przeglądarki&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Ponieważ nie wszystkie przeglądarki obsługują standardy &lt;strong&gt;W3C&lt;/strong&gt; w taki sam sposób to należy być ostrożnym wybierając sposób wyświetlania informacji. Biblioteki takie jak &lt;strong&gt;jQuery&lt;/strong&gt; lub &lt;strong&gt;Modernizer&lt;/strong&gt; pomagają w dostosowaniu wyglądu we wszystkich przeglądarkach.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Powszechną metodą wykrywania przeglądarki jest użycie &lt;strong&gt;Java Script&lt;/strong&gt; do sprawdzenia nagłówka &lt;strong&gt;userAgent&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład wykrywania czy przeglądarka użytkownika to &lt;em&gt;Microsoft Internet Explorer&lt;/em&gt;:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;script type="text/javascript"&amp;gt;
    if ( navigator.userAgent.indexOf("MSIE")&amp;gt;0 )
    {
        &amp;lt;!--[if lte IE 7]&amp;gt;
        &amp;lt;style TYPE="text/css"&amp;gt;
            @import url(ie7.css);
        &amp;lt;/style&amp;gt;
        &amp;lt;![endif]--&amp;gt;
    }
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Przykład sprawdzenia czy metoda &lt;strong&gt;window.addEventListener&lt;/strong&gt; jest wspierana przez przeglądarkę:&lt;/p&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;script type="text/javascript"&amp;gt;
    if(window.addEventListener)
    {
        // Browser supports "addEventListener"
        window.addEventListener("load", myFunction, false);
    }
    else if(window.attachEvent)
    {
        // Browser supports "attachEvent"
        window.attachEvent("onload", myFunction);
    }
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Ponieważ nie wszystkie przeglądarki w pełni wspierają &lt;strong&gt;HTML5&lt;/strong&gt; to zalecaną metodą obsługi niektórych cech jest użycie alternatyw dla tych właściwości kiedy przeglądarka nie potrafi obsłużyć zasobu. Przykładowo tag pozwala na użycie alternatywnych zasobów do wyświetlenia i jeżeli wszystkie zawiodą to jeszcze odnośnika z którego można pobrać materiał wideo, np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;video&amp;gt;
    &amp;lt;source src="video.mp4" type='video/mp4' /&amp;gt;
    &amp;lt;source src="video.webm" type='video/webm' /&amp;gt;
    &amp;lt;object type="application/x-silverlight-2"&amp;gt;
        &amp;lt;param name="source" value="http://url/player.xap"&amp;gt;
        &amp;lt;param name="initParams" value="m=http://url/video.mp4"&amp;gt;
    &amp;lt;/object&amp;gt;
    Download the video &amp;lt;a href="video.mp4"&amp;gt;here&amp;lt;/a&amp;gt;.
&amp;lt;/video&amp;gt;
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Aby obsłużyć wiele przeglądarek, w tym także przeglądarki urządzeń mobilnych można użyć różnych widoków dla specyficznych urządzeń lub użyć &lt;strong&gt;CSS3 media queries&lt;/strong&gt; i tagu .&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Informacje o dostępnych rodzajach widoków są dostępne w &lt;strong&gt;System.Web.Mvc.VirtualPathProviderViewEngine.DisplayModeProvider&lt;/strong&gt;. Domyślnie istnieją tam dwa wpisy &lt;strong&gt;mobile&lt;/strong&gt; i &lt;strong&gt;default&lt;/strong&gt;. Widok mobilny może być stworzony w tym samym folderze lecz musi posiadać słowo &lt;strong&gt;mobile&lt;/strong&gt; w nazwie np &lt;strong&gt;Index.Mobile.cshtml&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Dostosowanie widoku dla konkretnej platformy i przeglądarki jest możliwe dzięki &lt;strong&gt;DisplayModeProvider&lt;/strong&gt;. Przykład dodania dostosowania widoku dla &lt;em&gt;Windows Phone&lt;/em&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iemobile")
{
    ContextCondition = (context =&amp;gt; context.GetOverriddenUserAgent().IndexOf
        ("iemobile", StringComparison.OrdinalIgnoreCase) &amp;gt;= 0)
});
&lt;/pre&gt;
&lt;p style="margin: 0px 0px 1.2em !important;"&gt;Kiedy serwer otrzyma żądanie &lt;strong&gt;iemobile&lt;/strong&gt; to będzie próbował znaleźć widok &lt;strong&gt;Index.iemobile.cshtml&lt;/strong&gt;.&lt;/p&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Aby aplikacja była responsywna i dostosowywała się do rozmiarów przeglądarki można użyć stylu &lt;strong&gt;CSS&lt;/strong&gt; i dodanie tagu . Dodatkowo można użyć &lt;strong&gt;@media query&lt;/strong&gt; które sprawdzają pewne funkcje multimedialne jak szerokość, wysokość i kolory np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;/* header */
header .content-wrapper {
    padding-top: 20px;
}
/* logo */
.site-title {
    color: #c8c8c8;
    font-family: Rockwell, Consolas, "Courier New", Courier, monospace;
    font-size: 2.3em;
    margin: 0;
}
@media only screen and (max-width: 850px) {
    /* header mobile */
    header .float-left,
    header .float-right {
        float: none;
    }
    /* logo mobile */
    header .site-title {
        margin: 10px;
        text-align: center;
    }
&lt;/pre&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Aby właściwości &lt;strong&gt;CSS3&lt;/strong&gt; działały dobrze we wszystkich przeglądarkach można użyć rozszerzeń specyficznych dla dostawcy (&lt;strong&gt;vendor prefix&lt;/strong&gt;) np &lt;strong&gt;-ms-, -mso-&lt;/strong&gt; dla &lt;em&gt;Microsoft&lt;/em&gt;, &lt;strong&gt;-moz-&lt;/strong&gt; dla &lt;em&gt;Mozilla&lt;/em&gt;, &lt;strong&gt;-webkit-&lt;/strong&gt; dla &lt;em&gt;Google i Apple&lt;/em&gt; i &lt;strong&gt;-o-, -xv-&lt;/strong&gt; dla &lt;em&gt;Opera&lt;/em&gt;. Przykład &lt;strong&gt;CSS&lt;/strong&gt; z rozszerzeniami specyficznymi dla dostawcy:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;&amp;lt;style&amp;gt;
.corners
{
    width: 350px;
    margin: 0px;
    background-color: #222;
    color: #fff;
    padding: 8px;
    /* regular style */
    border-radius: 15px;
    /* -moz extension */
    -moz-border-radius: 18px;
}
&amp;lt;/style&amp;gt;
&lt;/pre&gt;
&lt;h2 style="margin: 1.3em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.4em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #eeeeee;"&gt;Planowanie responsywnego układu UI&lt;/h2&gt;
&lt;ul style="margin: 1.2em 0px; padding-left: 2em;"&gt;
&lt;li style="margin: 0.5em 0px;"&gt;&lt;strong&gt;ASP.NET MVC&lt;/strong&gt; obsługuje wiele podejść dla użytkowników mobilnych. Można utworzyć nadpisane widoki, które są uniwersalne dla każdego urządzenia mobilnego lub specyficzne dla urządzenia. &lt;strong&gt;System.Web.Mvc.VirtualPathProviderViewEngine.DisplayModeProvider&lt;/strong&gt; ocenia przychodzące żądania i na podstawie wartości &lt;strong&gt;userAgent&lt;/strong&gt; przekierowuje do skonfigurowanego &lt;strong&gt;DisplayModeProviders&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Innym sposobem jest użycie tagu &lt;strong&gt;viewport&lt;/strong&gt; i &lt;strong&gt;@media queries&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Biblioteka z repozytorium &lt;strong&gt;jQuery Mobile MVC&lt;/strong&gt; umożliwia wykorzystanie znaczników, aby zapewnić dodatkowe funkcje obsługiwane przez przeglądarkę klienta. Jeśli przeglądarka nie obsługuje funkcjonalności, biblioteka &lt;strong&gt;jQuery&lt;/strong&gt; będzie obniżać funkcjonalności.&lt;/li&gt;
&lt;li style="margin: 0.5em 0px;"&gt;Można zmodyfikować plik &lt;strong&gt;global.asax&lt;/strong&gt; w celu dostosowania różnych przeglądarek mobilnych, np:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre style="font-size: 1em; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 1.2em; margin: 1.2em 0px;"&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.WebPages;
namespace MvcApplication
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            DisplayModeProvider.Instance.Modes.Insert(0, new
                DefaultDisplayMode("windows")
            {
                ContextCondition = (context =&amp;gt; context.GetOverriddenUserAgent().IndexOf
                    ("Windows", StringComparison.OrdinalIgnoreCase) &amp;gt;= 0)
            });
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
        }
    }
}
&lt;/pre&gt;
&lt;div style="height: 0; width: 0; max-height: 0; max-width: 0; overflow: hidden; font-size: 0em; padding: 0; margin: 0;"&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Sun, 31 Jul 2016 12:47:54 Z</pubDate>
      <a10:updated>2016-07-31T12:47:54Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1129</guid>
      <link>http://smsoft.pl/blog/xi-szyfrowanie-i-zarzadzanie-assembly/</link>
      <title>XI. Szyfrowanie i zarządzanie assembly</title>
      <description>&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/h2&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Szyfrowanie symetryczne i asymetryczne&lt;/strong&gt; - wybór odpowiedniego algorytmu szyfrowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Certyfikaty&lt;/strong&gt; - tworzenie i zarządzanie certyfikatami, różne rodzaje certyfikatów i magazyny certyfikatów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Klucze szyfrujące&lt;/strong&gt; - tworzenie i zarządzanie kluczami szyfrującymi w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security&lt;/strong&gt; - implementacja przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Hash data&lt;/strong&gt; - tworzenie podpisów cyfrowych i opcje tworzenia skrótów danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Strumienie szyfrowane&lt;/strong&gt; - użycie klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt; do szyfrowania strumieni.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Zarządzanie assembly&lt;/strong&gt; - wersjonowanie, podpisywani używając silnych nazw za pomocą &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; oraz &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sn.exe&lt;/em&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; i użycie technik pozwalających na użycie assembly o różnych wersjach na tej samej maszynie.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Użycie szyfrowania&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Szyfrowanie (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Encryption&lt;/em&gt;) jest procesem transformacji danych, który utrudnia osobie nieupoważnionej, aby odczytała te dane. Dane zaszyfrowane nazywane są szyfrogramem (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ciphertext&lt;/em&gt;). Odszyfrowywanie (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Decryption&lt;/em&gt;) jest procesem odwrotnym który przekształca zaszyfrowane dane w zwykłe dane. Im trudniej jest odszyfrować dane tym lepszy jest algorytm szyfrujący. Nie ma szyfrów niemożliwych do odszyfrowania ale niektóre algorytmy szyfrujące są tak skomplikowane, że czas ich odszyfrowania może zajmować bardzo długi czas.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wybór odpowiedniego algorytmu szyfrującego&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Szyfrowanie może być wykonywane na dwa sposoby. Pierwszy zwany jest szyfrowaniem symetrycznym (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;symmetric encryption&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;shared secret&lt;/em&gt;) a drugi zwany jest szyfrowaniem niesymetrycznym (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;asymmetric encryption&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;public key&lt;/em&gt;).&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; algorytmy szyfrowania zaimplementowane są na trzy sposoby:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy zarządzane - nazwy tych klas składają się z nazwy algorytmu i sufiksu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Managed&lt;/em&gt;, np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RijndaelManaged&lt;/strong&gt; dla algorytmu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Rijndael&lt;/em&gt;. Zarządzane implementacje są nieco wolniejsze od innych implementacji i nie są certyfikowane przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Federal Information Processing Standards (FIPS)&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy opakowujące natywną implementację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Cryptography API (CAPI)&lt;/strong&gt; - nazwy tych klas składają się z nazwy algorytmu i sufiksu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CryptoServiceProvider&lt;/em&gt;, np klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DESCryptoServiceProvider&lt;/strong&gt; dla algorytmu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DES&lt;/em&gt;. Implementacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CAPI&lt;/em&gt; są odpowiednie dla starszych systemów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy opakowujące natywną implementację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Cryptography Next Generation API (CNG)&lt;/strong&gt; - nazwy tych klas składają się z nazwy algorytmu i sufiksu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CNG&lt;/em&gt;, np klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDiffieHellmanCng&lt;/strong&gt; dla algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDH&lt;/strong&gt;. Algorytmy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CNG&lt;/em&gt; mogą być używane w systemach od &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows Vista&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie klasy szyfrujące są zdefiniowane w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography&lt;/strong&gt; i są częścią rdzenia biblioteki &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Szyfrowanie symetryczne&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Szyfrowanie symetryczne wykonywane jest za pomocą klucza szyfrującego, który m jest tablica bajtowa. Ten sam klucz używany jest również do odszyfrowania danych. Algorytmy symetryczne polegają na tym, że tylko uprawniona osoba posiada dostęp do klucza szyfrującego. &lt;br /&gt;Algorytmy symetryczne w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; używają trybu łańcuchowego nazywanego &lt;em style="box-sizing: border-box; outline: none !important;"&gt;cipher block chaining&lt;/em&gt;. Taki rodzaj algorytmów działa w następujący sposób. Jeżeli ilość danych jest większa niż zdefiniowana wielkość bloku, to są dzielone na mniejsze bloki o zdefiniowanym rozmiarze. Pierwszy blok jest szyfrowany używając losowego bloku danych o tym samym rozmiarze, zwanym wektorem inicjującym (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;initialization vector&lt;/em&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IV&lt;/em&gt;), oraz kluczem szyfrującym. Następne bloki są szyfrowane używając wyniku poprzedniego bloku i tego samego klucza. Rozmiar bloku zależy od algorytmu. Jeżeli ostatni blok jest mniejszy niż rozmiar, będzie dopełniony danymi do pełnego rozmiaru bloku. Aby odszyfrować dane trzeba posiadać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; oraz klucz szyfrujący. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; nie musi być trzymany w tajemnicy ale klucz szyfrujący owszem. &lt;br /&gt;Algorytmy symetryczne implementowane w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AES&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Advanced Encryption Standard&lt;/em&gt;. Ten algorytm jest implementowany przez dwie klasy: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AesManaged&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AesCryptoServiceProvider&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DES&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Data Encryption Standard&lt;/em&gt;. Ten algorytm jest implementowany przez klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DESCryptoServiceProvider&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RC2&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Rivest Cipher&lt;/em&gt;. Ten algorytm jest implementowany przez klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RC2CryptoServiceProvider&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rijndael&lt;/strong&gt; - Ten algorytm jest implementowany przez klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RijndaelManaged&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TripleDES&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Triple Data Encryption Standard&lt;/em&gt;. Ten algorytm jest implementowany przez klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TripleDESCryptoServiceProvider&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie te klasy dziedziczą z klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.SymmetricAlgorithm&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SymmetricAlgorithm&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BlockSize&lt;/strong&gt; - pobiera lub ustawia rozmiar bloku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FeedbackSize&lt;/strong&gt; - pobiera lub ustawia rozmiar informacji zwrotnych. Rozmiar ten reprezentuje ilość danych w bitach, które są zawracane do następnej operacji szyfrowania lub odszyfrowywania. Rozmiar ten musi być mniejszy niż rozmiar bloku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; - pobiera lub ustawia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt;. Kiedy tworzymy nową instancje algorytmu symetrycznego to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; generowane. Można również wygenerować je za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GenerateIV&lt;/strong&gt;. Rozmiar &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; musi być taki sam jak rozmiar bloku podzielony przez osiem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Key&lt;/strong&gt; - pobiera lub ustawia klucz szyfrujący. Poprawne wielkości klucza szyfrującego zależne są od algorytmu i są wymienione w liście &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LegalKeySizes&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;KeySize&lt;/strong&gt; - pobiera lub ustawia rozmiar klucza szyfrującego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LegelBlockSizes&lt;/strong&gt; - Pobiera listę dozwolonych wartości rozmiaru bloku dla konkretnego algorytmu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LegalKeySizes&lt;/strong&gt; - Pobiera listę dozwolonych wartości rozmiaru klucza dla konkretnego algorytmu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Mode&lt;/strong&gt; - pobiera lub ustawia tryb operacji algorytmu. Wartości są enumeracją &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.CipherMode&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Padding&lt;/strong&gt; - pobiera lub ustawia tryb wypełnienia używany przez algorytm. Wartości są enumeracją &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.PaddingMode&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista metod klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SymmetricAlgorithm&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; - zwalnia wszystkie zasoby używane przez klasę algorytmu. Należy wywołać te metodę aby zwolnić wszystkie zasoby po zakończeniu pracy z obiektem szyfrującym.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create()&lt;/strong&gt; - metoda statyczna tworząca nowy obiekt szyfrujący z domyślnym algorytmem, dla &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.5&lt;/em&gt; jest to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RijndaelManaged&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create(String)&lt;/strong&gt; - metoda statyczna tworząca nowy obiekt szyfrujący z wybranym algorytmem. Nazwa może być nazwą algorytmu lub nazwą klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateDecryptor()&lt;/strong&gt; - tworzy obiekt odszyfrowujący używając klucza i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; zdefiniowanych we właściwościach obiektu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateDecryptor(Byte[], Byte[])&lt;/strong&gt; - tworzy obiekt odszyfrowujący używając klucza i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; zdefiniowanych jako parametry.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateEncryptor()&lt;/strong&gt; - tworzy obiekt szyfrujący używając klucza i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; zdefiniowanych we właściwościach obiektu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateEncryptor(Byte[], Byte[])&lt;/strong&gt; - tworzy obiekt odszyfrowujący używając klucza i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; zdefiniowanych jako parametry.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GenerateIV&lt;/strong&gt; - tworzy losowy wektor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; używany przez algorytm. Zwykle nie wywołuje się tej metody bezpośrednio.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GenerateKey&lt;/strong&gt; - generuje losowy klucz używany przez algorytm.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ValidKeySize&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli rozmiar klucza jest odpowiedni dla danego algorytmu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przebieg szyfrowania zwykłego tekstu algorytmem symetrycznym jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt algorytmu symetrycznego poprzez wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SymmetricAlgorithm&lt;/strong&gt;, opcjonalnie ustawiając parametr z nazwą wybranego algorytmu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli chcemy to możemy ustawić klucz szyfrujący i wektor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt;, lecz nie jest to wymagane gdyż są one domyślnie generowane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Generujemy obiekt szyfrujący wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateEncryptor&lt;/strong&gt;. Można wybrać klucz i wektor lecz nie jest to konieczne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołujemy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformFinalBlock&lt;/strong&gt; na obiekcie szyfrującym, która pobiera na wejściu tablicę bajtową reprezentującą dane, offset - gdzie zacząć szyfrowanie i długość danych do szyfrowania. Metoda zwraca zaszyfrowane dane.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład szyfrowania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] EncryptData(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] plainData, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] IV, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;key&lt;/span&gt;) {&lt;br /&gt;&lt;br /&gt;    SymmetricAlgorithm cryptoAlgorythm = SymmetricAlgorithm.Create();&lt;br /&gt;&lt;br /&gt;    ICryptoTransform encryptor = cryptoAlgorythm.CreateEncryptor(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;key&lt;/span&gt;, IV);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] cipherData = encryptor.TransformFinalBlock(plainData, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;br /&gt;        plainData.Length);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; cipherData;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przebieg odszyfrowania zaszyfrowanego tekstu algorytmem symetrycznym jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt algorytmu symetrycznego poprzez wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SymmetricAlgorithm&lt;/strong&gt;, opcjonalnie ustawiając parametr z nazwą wybranego algorytmu który został użyty do szyfrowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli chcemy to możemy ustawić klucz szyfrujący i wektor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt;, lecz nie jest to wymagane ponieważ można podać je później.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt odszyfrowujący wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateDecryptor&lt;/strong&gt;. Jeżeli nie podaliśmy klucza i wektora wcześniej to teraz musimy je ustawić. Klucz szyfrujący i wektor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt; muszą być takie same jak przy szyfrowaniu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołujemy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformFinalBlock&lt;/strong&gt; na obiekcie odszyfrowującym, który pobiera na wejściu tablicę bajtową z zaszyfrowanymi danymi, offset - gdzie zacząć odszyfrowywanie i długość danych do odszyfrowywania. Metoda zwraca odszyfrowane dane.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład odszyfrowania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] DecryptData(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] cipherData, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] IV, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;key&lt;/span&gt;) {&lt;br /&gt;&lt;br /&gt;    SymmetricAlgorithm cryptoAlgorythm = SymmetricAlgorithm.Create();&lt;br /&gt;&lt;br /&gt;    ICryptoTransform decryptor = cryptoAlgorythm.CreateDecryptor(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;key&lt;/span&gt;, IV);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;byte&lt;/span&gt;[] plainData = decryptor.TransformFinalBlock(cipherData, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;,&lt;br /&gt;        cipherData.Length);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; plainData;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Największym wyzwaniem przy użyciu algorytmów symetrycznych jest zachowanie tajności klucza szyfrującego.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Szyfrowanie asymetryczne&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Głównym powodem używania szyfrowania asymetrycznego jest uniknięcie udostępniania klucza szyfrowania. Szyfrowanie asymetryczne używa dwóch matematycznie powiązanych kluczy, które uzupełniają się nawzajem. Wiadomość zaszyfrowana jednym z nich może być odszyfrowana jedynie drugim. Jeden klucz jest kluczem publicznym którym dane są szyfrowane. Drugi klucz który służy do odszyfrowania wiadomości nazywany jest kluczem prywatnym.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Szyfrowanie asymetryczne jest wolniejsze od symetrycznego, lecz jego największą zaletą jest to, że nie potrzeba przekazywać klucza szyfrującego aby algorytm działał.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Algorytmy asymetryczne implementowane w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DSA&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Digital Signature Algorithm&lt;/em&gt;. Służy do tworzenia podpisów cyfrowych, które pomagają chronić integralność danych. Klasa implementująca ten algorytm to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DSACryptoServiceProvider&lt;/strong&gt;. Algorytmu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DSA&lt;/em&gt; należy używać jedynie dla zgodności z przestarzałymi aplikacjami.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDiffieHellman&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Elliptic Curve Diffie-Hellman Algorithm&lt;/em&gt;. Klasa implementująca ten algorytm to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDiffieHellmanCng&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDsa&lt;/strong&gt; - &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Elliptic Curve Digital Signature Algorithm (ECDSA)&lt;/em&gt;. Klasa implementująca ten algorytm to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDsaCng&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RSA&lt;/strong&gt; - Klasa implementująca ten algorytm to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RSACryptoServiceProvider&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie te klasy dziedziczą z klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.AsymmetricAlgorithm&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przebieg szyfrowania zwykłego tekstu algorytmem asymetrycznym jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Uzyskania klucza publicznego odbiorcy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Utworzenie nowego obiektu asymetrycznego szyfrowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Ustawienie klucza publicznego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Szyfrowanie danych&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wysłanie danych do odbiorcy.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przebieg odszyfrowania zaszyfrowanej wiadomości algorytmem asymetrycznym jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Odebranie danych od wysyłającego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Utworzenie nowego obiektu asymetrycznego szyfrowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Ustawienie klucza prywatnego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Odszyfrowanie danych.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli dane zostały zmienione lub nie zostały zaszyfrowane odpowiadającym kluczem publicznym to zgłoszony zostanie wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptographicException&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieją dwa sposoby obsługi kluczy. Pierwszy polega na bezpośrednim wysłaniu klucza publicznego. Drugi polega na umieszczeniu klucza w pojemniku dostawcy usług kryptograficznych.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jednym z typowych scenariuszy jest użycie szyfrowania asymetrycznego do wymiany kluczy potrzebnych do szyfrowania symetrycznego stosując następujący przepływ:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obie strony generują pary kluczy prywatnych i publicznych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Strony wymieniają się kluczami publicznymi.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Każda ze stron generuje klucz symetryczny który może służyć do szyfrowania danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Każda ze stron szyfruje klucz symetryczny używając algorytmu asymetrycznego i klucza publicznego otrzymanego od drugiej strony.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Każda ze stron wysyła zaszyfrowany klucz symetryczny do drugiej strony.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obie strony używają swojego klucza prywatnego do odszyfrowania klucza szyfrowania symetrycznego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Strony zaczynają wymieniać się danymi używając algorytmu symetrycznego i klucza z poprzedniego kroku.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Innym typowym scenariuszem jest użycie szyfrowania asymetrycznego do podpisania danych, zapewniając w ten sposób zarówno autentyczność i tożsamość.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Szyfrowanie strumieni&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Strumienie reprezentują plik, urządzenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; lub kanał komunikacyjny i potrafią wykonywać trzy podstawowe zadania:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - można czytać dane ze strumienia do struktury danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; - można zapisać dane ze struktury danych do strumienia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Seek&lt;/strong&gt; - można zmienić aktualną pozycję w strumieniu gdzie następna operacja odczytu lub zapisu działa.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Bardzo ważną właściwością strumieni w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; jest to, że mogą być łączone poprzez przekazywanie danych wyjściowych ze strumienia do wejścia innego strumienia. Czasami chcemy aby dane przechodzące przez strumień były zaszyfrowane. Można zaszyfrować dane przed wysłaniem do strumienia bądź połączyć strumienie tak aby jeden z nich odpowiadał za szyfrowanie. Jednym ze strumieni w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt;, który potrafi szyfrować i deszyfrować dane które przez niego przechodzą.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Praca ze strumieniami szyfrowanymi wygląda następująco:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt algorytmu symetrycznego poprzez wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SymmetricAlgorithm&lt;/strong&gt;, opcjonalnie wybierając nazwę algorytmu szyfrującego jako parametr wejściowy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli chcemy to możemy ustawić klucz szyfrujący i wektor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt;, lecz nie jest to wymagane gdyż są one domyślnie generowane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt szyfrujący wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateEncryptor&lt;/strong&gt;. Można wybrać klucz i wektor lecz nie jest to konieczne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt strumienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt;. Konstruktor przyjmuje trzy parametry. Pierwszym jest strumień szyfrowanych danych; drugi to obiekt szyfrujący; trzeci to tryb strumienia który w tym wypadku to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapisujemy dane do obiektu strumienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt; wywołując jedną z metod zapisu udostępnianych przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt;, używając &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt;, lub łącząc go z innym strumieniem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy skończymy zapis należy wyczyścić obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt; wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; po czym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowy blok kodu demonstrujący taką operację:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] EncryptString(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; plainData, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] IV, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] key) {&lt;br /&gt;&lt;br /&gt;    SymmetricAlgorithm cryptoAlgorythm = SymmetricAlgorithm.Create();&lt;br /&gt;&lt;br /&gt;    ICryptoTransform encryptor = cryptoAlgorythm.CreateEncryptor(key, IV);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] cipherData = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (MemoryStream msEncrypt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MemoryStream()) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (CryptoStream csEncrypt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CryptoStream(msEncrypt,&lt;br /&gt;                encryptor,&lt;br /&gt;                CryptoStreamMode.Write)) {&lt;br /&gt;&lt;br /&gt;            StreamWriter swEncrypt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamWriter(csEncrypt);&lt;br /&gt;&lt;br /&gt;            swEncrypt.Write(plainData);&lt;br /&gt;            swEncrypt.Close();&lt;br /&gt;            csEncrypt.Clear();&lt;br /&gt;            cipherData = msEncrypt.ToArray();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; cipherData;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Odszyfrowanie strumienia wygląda następująco:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt algorytmu symetrycznego poprzez wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SymmetricAlgorithm&lt;/strong&gt;, opcjonalnie wybierając nazwę algorytmu szyfrującego jako parametr wejściowy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli chcemy to możemy ustawić klucz szyfrujący i wektor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt;, możemy również uczynić to w następnym kroku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt deszyfrujący wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateDecryptor&lt;/strong&gt;. Jeżeli nie uczyniliśmy tego wcześniej to teraz trzeba wybrać klucz i wektor które zostały użyte do szyfrowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt strumienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt;. Konstruktor przyjmuje trzy parametry. Pierwszym jest strumień szyfrowanych danych; drugi to obiekt deszyfrujący; trzeci to tryb strumienia który w tym wypadku to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Odczytujemy dane z obiektu strumienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt; za pomocą jednej z jego metod odczytu, używając obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; lub połączenia do innego strumienia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy skończymy zapis należy wyczyścić obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt; wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; po czym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowy blok kodu demonstrujący taką operację:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DecryptString&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;byte&lt;/span&gt;[] cipherData, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;byte&lt;/span&gt;[] IV, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;byte&lt;/span&gt;[] key&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;    SymmetricAlgorithm cryptoAlgorythm = SymmetricAlgorithm.Create();&lt;br /&gt;&lt;br /&gt;    ICryptoTransform decryptor = cryptoAlgorythm.CreateDecryptor(key, IV);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; plainText = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (MemoryStream msDecrypt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MemoryStream(cipherData)) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (CryptoStream csDecrypt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CryptoStream(msDecrypt,&lt;br /&gt;                decryptor,&lt;br /&gt;                CryptoStreamMode.Read)) {&lt;br /&gt;&lt;br /&gt;            StreamReader srDecrypt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamReader(csDecrypt);&lt;br /&gt;&lt;br /&gt;            plainText = srDecrypt.ReadToEnd();&lt;br /&gt;            srDecrypt.Close();&lt;br /&gt;            csDecrypt.Clear();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; plainText;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Bardzo często spotykanym scenariuszem jest zaszyfrowanie i skompresowanie danych po czym wysłanie ich przez sieć. Kompresowanie tekstu jest bardziej efektywne niż danych binarnych więc należy zacząć od operacji kompresji danych po czym dopiero je zaszyfrować. Strona odbierająca musi wykonać operacje w odwrotnej kolejności.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Funkcja skrótu danych (Hash)&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Funkcja skrótu to proces mapowania danych binarnych o zmiennej długości do danych binarnych stałego rozmiaru. Stosowanie tej samej funkcji skrótu do dwóch identycznych struktur danych, daje taki sam efekt. &lt;br /&gt;Funkcje skrótu są używane w kilku standardowych scenariuszach:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Indeksowanie danych&lt;/strong&gt; - zamiast dopasować dane, gdy klucz indeksu posiada zmienną długość, można obliczyć &lt;br /&gt;wartość skrótu klucza indeksu i wyszukiwać tą wartość zamiast klucza. Wartość funkcji skrótu jest zwykle krótsza niż oryginalna wartość, więc jej wyszukiwanie jest zwykle szybsze. Istnieje możliwość, że dwa lub więcej kluczy indeksu może wywoływać tę samą wartość skrótu. W takim wypadku algorytm indeksujący używa techniki zwanej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;hash bucket&lt;/strong&gt; gdzie wartości indeksu posiadające tą samą wartość skrótu są grupowane razem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Integralność danych&lt;/strong&gt; - integralności danych stosuje się w celu zapewnienia, że dane dotrą do miejsca przeznaczenia bez zmian. Nadawca oblicza kryptograficzny skrót danych, które chce wysłać, a następnie wysyła te dane, skrót i informacje o technice stosowanej do obliczenia skrótu do odbiorcy. Odbiorca może zastosować ten sam algorytm na danych i porównać wynik z otrzymanymi danymi. Jeżeli są takie same to znaczy, że dane nie uległy zmianie po wykonaniu skrótu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Autentyczność danych&lt;/strong&gt; - autentyczności danych stosuje się, gdy odbiorca chce upewnić się, że dane pochodzą od właściwego nadawcy i, że nie zmieniły się po drodze. Nadawca oblicza kryptograficzny skrót danych i podpisuje go własnym kluczem prywatnym. Odbiorca tworzy ponownie skrót i odszyfrowuje otrzymany podpis używając klucza publicznego wysyłającego po czym porównuje dane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Przechowywanie haseł&lt;/strong&gt; - przechowywanie haseł jako zwykły tekst jest niebezpieczną i niezalecaną techniką. Aby chronić hasła zwykle stosuje się do nich funkcje skrótu przed ich zapisaniem.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieją dwa rodzaje algorytmów funkcji skrótów: z kluczem lub bez klucza. Algorytmy bez klucza są zwykle używane tylko w scenariuszach integralności danych.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista Algorytmów tworzenia skrótów zaimplementowanych w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA1&lt;/strong&gt; - implementacja algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA&lt;/strong&gt; tworząca skrót o rozmiarze 160 bitów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA256&lt;/strong&gt; - implementacja algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA&lt;/strong&gt; tworząca skrót o rozmiarze 256 bitów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA512&lt;/strong&gt; - implementacja algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA&lt;/strong&gt; tworząca skrót o rozmiarze 512 bitów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA384&lt;/strong&gt; - implementacja algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA&lt;/strong&gt; tworząca skrót o rozmiarze 384 bitów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MD5&lt;/strong&gt; - implementacja algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Md5&lt;/strong&gt;. Używaj tylko dla kompatybilności ze starymi aplikacjami.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RIPEMD160&lt;/strong&gt; - implementacja algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RIPEMD&lt;/strong&gt;. Używaj tylko dla kompatybilności ze starymi aplikacjami.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie klasy skrótów dziedziczą z abstrakcyjnej klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.HashAlgorithm&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HashAlgorithm&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CanReuseTransform&lt;/strong&gt; - właściwość tylko do odczytu zwracająca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli aktualna transformacja może być użyta ponownie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CanTransformMultipleBlocks&lt;/strong&gt; - właściwość tylko do odczytu zwracająca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli wiele bloków może być transformowanych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Hash&lt;/strong&gt; - właściwość tylko do odczytu zwracająca obliczoną wartość skrótu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HashSize&lt;/strong&gt; - właściwość tylko do odczytu zwracająca rozmiar obliczonego skrótu w bitach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InputBlockSize&lt;/strong&gt; - właściwość tylko do odczytu zwracająca rozmiar bloku wejściowego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OutputBlockSize&lt;/strong&gt; - pobiera rozmiar bloku wyjściowego.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HashAlgorithm&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; - zwalnia wszystkie używane zasoby.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ComputeHash(Byte[])&lt;/strong&gt; - wylicza skrót dla tablicy bajtów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ComputeHash(Stream)&lt;/strong&gt; - wylicza skrót dla strumienia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ComputeHash(Byte[], Int32, Int32)&lt;/strong&gt; - wylicza skrót dla regionu w tablicy bajtów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create()&lt;/strong&gt; - tworzy nowy obiekt algorytmu skrótów używając domyślnego algorytmu, w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.5&lt;/em&gt; jest to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SHA1&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create(String)&lt;/strong&gt; - tworzy nowy obiekt algorytmu skrótów używając wybranego algorytmu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformBlock&lt;/strong&gt; - oblicza skrót dla określonego regionu wejściowej tablicy bajtowej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;inputBuffer&lt;/em&gt; i kopiuje wynik do określonego regionu w tablicy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;outputBuffer&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformFinalBlock&lt;/strong&gt; - oblicza skrót dla określonego regionu wejściowej tablicy bajtowej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;inputBuffer&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zwykle używamy tylko metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ComputeHash&lt;/strong&gt;. Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformBlock&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformFinalBlock&lt;/strong&gt; są używane gdy chcemy obliczyć skrót tylko dla części danych.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Algorytmy skrótów z kluczem dziedziczą z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.KeyedHashAlgorithm&lt;/strong&gt;. &lt;br /&gt;W porównaniu z algorytmami bez klucza klasa&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;KeyedHashAlgorithm&lt;/strong&gt; posiada jedną istotną właściwość:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Key&lt;/strong&gt; - pobiera lub ustawia wartość klucza używanego przez algorytm. jeżeli chcemy zmienić klucz po rozpoczęciu operacji tworzenia skrótu to zgłoszony zostanie wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptographicException&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Schemat działania przy tworzeniu skrótu jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt algorytmu funkcji skrótu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli algorytm używa klucza to ustawiamy wartość klucza.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołujemy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ComputeHash&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapisujemy skrót danych.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowy blok kodu demonstrujący taką operację:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ComputeHash&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; input&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    HashAlgorithm sha = SHA256.Create();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] hashData = sha.ComputeHash(Encoding.Default.GetBytes(input));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; Convert.ToBase64String(hashData);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Schemat działania przy weryfikacji skrótu dla danych jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt algorytmu funkcji skrótu taki sam jak przy tworzeniu skrótu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli algorytm używa klucza to ustawiamy wartość klucza taką samą jak przy tworzeniu skrótu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyodrębniamy oryginalny skrót danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołujemy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ComputeHash&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Porównujemy oryginalny skrót z tym wyliczonym.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowy blok kodu demonstrujący taką operację:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;VerifyHash&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; input, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; hashValue&lt;/span&gt;) &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    HashAlgorithm sha = SHA256.Create();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] hashData = sha.ComputeHash(Encoding.Default.GetBytes(input));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; Convert.ToBase64String(hashData) == hashValue;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Tworzenie i zarządzanie certyfikatami&lt;/h3&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Kiedy dwie strony komunikują się ze sobą to muszą mieć pewność, że porozumiewają się z właściwym partnerem. Przykładowo kiedy wykonujemy transakcje bankową w internecie, chcemy mieć pewność, że jesteśmy na stronie naszego banku a nie na innej stronie która podszywa się pod stronę naszego banku. Chcemy wiedzieć również, że komunikacja jest bezpieczna. Dla aplikacji sieciowych istnieją dwa protokoły które rozwiązują ten problem: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Transport Layer Security (TLS)&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Secure Socket Layer (SSL)&lt;/strong&gt;. Oba te protokoły szyfrują dane i zapewniają autentyczność danych. Dla autentyczności używają &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Public Key Infrastructure (PKI)&lt;/strong&gt;, która jest niezbędna do obsługi certyfikatów cyfrowych. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PKI&lt;/strong&gt; używa notacji nazywanej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Certificate Authority (CA)&lt;/strong&gt;. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CA&lt;/strong&gt; jest to jednostka która wystawia certyfikaty cyfrowe. Certyfikaty cyfrowe wiąże klucz publiczny z tożsamością. Dzięki temu, kiedy dwie strony chcą się komunikować i nadawca chce się upewnić, że komunikuje się z odpowiednim odbiorcą, nadawca może użyć &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PKI&lt;/strong&gt; do zweryfikowania tożsamości odbiorcy. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Zasada działania jest prosta. Można albo wybrać bezpośrednio, że ufamy drugiej stronie albo zaufać trzeciej stronie która weryfikuje tożsamość innych podmiotów. Druga opcja jest hierarchiczna, co oznacza, że liczba jednostek którym zdecydujesz się zaufać jest ograniczona. Lecz te jednostki mogą weryfikować tożsamość innych podmiotów co czyni je również podmiotami zaufanymi itd.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Certyfikaty najwyższego poziomu, którym zdecydujesz się zaufać nazywane są certyfikatami głównymi (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;root certificates&lt;/em&gt;). Normalnie nie dodajemy żadnego certyfikatu głównego. Przychodzą one wraz z instalacją systemu operacyjnego lub jego aktualizacjami. Certyfikaty najwyższego poziomu którym ufa nasz komputer można podejrzeć w panelu sterowania w opcjach internetowych. W zakładce &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Content&lt;/em&gt; należy kliknąć guzik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Certyficates&lt;/strong&gt; i wybrać zakładkę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trusted Root Certification Authorities&lt;/strong&gt;. Okno powinno być podobne do poniższego:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;a rel="attachment wp-att-663" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1457878534340.png"&gt;&lt;img class="aligncenter wp-image-663 size-medium" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1457878534340-300x276.png" alt="1457878534340" width="300" height="276" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;jeżeli strona chce aby jej tożsamość była gwarantowana, musi jedynie zweryfikować jej tożsamość w jednym z podmiotów które darzysz zaufaniem. Jednym z przykładów jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt;. Na komputerze istnieje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Root Certificate Authority&lt;/strong&gt; zwane &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GTE CyberTrust Global Root&lt;/strong&gt;. jeżeli wprowadzimy do przeglądarki adres &lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="https://www.microsoft.com/" target="_blank"&gt;https://www.microsoft.com&lt;/a&gt; i podejrzymy certyfikat strony to zobaczymy dialog podobny do poniższego:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;a rel="attachment wp-att-662" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1457878482778.png"&gt;&lt;img class="aligncenter size-medium wp-image-662" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1457878482778-241x300.png" alt="1457878482778" width="241" height="300" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Standard który jest używany przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PKI&lt;/strong&gt; to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X.509&lt;/strong&gt;, który określa format &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PKIs&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Certificate Revocation List (CLR)&lt;/strong&gt;, atrybuty certyfikatów i sposób walidacji ścieżek certyfikatów. &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; implementuje standard &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X.509&lt;/strong&gt;. Wszystkie klasy które są potrzebne do zarządzania certyfikatami znajdują się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography.X509Certificates&lt;/strong&gt;. Jeżeli posiadamy klucz prywatny który jest zainstalowany lokalnie to możemy odszyfrować dane zapisane odpowiadającym mu kluczem publicznym.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; oferuje używanie narzędzia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Makecert.exe (Certificate Creation Tool)&lt;/strong&gt;, które może być używane do tworzenia certyfikatów.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Do pracy programistycznej z certyfikatami można użyć klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X509Certificate2&lt;/strong&gt;. &lt;br /&gt;Certyfikaty używają pojęcia magazynów certyfikatów, które są miejscami, w których certyfikaty są bezpiecznie przechowywane. W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; magazyny są zaimplementowane w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X509Store&lt;/strong&gt;. System &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows&lt;/em&gt; oferuje dwie lokacje dla magazynów, które są reprezentowane przez enumerację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StoreLocation&lt;/strong&gt;. &lt;br /&gt;Wartości enumeracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StoreLocation&lt;/strong&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CurrentUser&lt;/strong&gt; - magazyn certyfikatów aktualnego użytkownika.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LocalMachine&lt;/strong&gt; - magazyn certyfikatów wspólny dla wszystkich użytkowników na maszynie lokalnej.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;System &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows&lt;/em&gt; oferuje osiem predefiniowanych magazynów które są reprezentowane przez enumerację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StoreName&lt;/strong&gt;. Możliwe wartości enumeracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StoreName&lt;/strong&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddressBook&lt;/strong&gt; - magazyn certyfikatów dla innych użytkowników.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AuthRoot&lt;/strong&gt; - magazyn certyfikatów dla niezależne urzędów certyfikacji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CA&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CertificateAuthority&lt;/strong&gt; - magazyn certyfikatów dla pośrednich &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CA&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Disallowed&lt;/strong&gt; - magazyn unieważnionych certyfikatów.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;My&lt;/strong&gt; - magazyn certyfikatów personalnych.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Root&lt;/strong&gt; - magazyn certyfikatów dla zaufanych głównych urzędów certyfikacji.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TrustedPeople&lt;/strong&gt; - magazyn certyfikatów dla bezpośrednio zaufanych ludzi i zasobów.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TrustedPublisher&lt;/strong&gt; - magazyn certyfikatów dla bezpośredniego zaufanych wydawców.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X509Store&lt;/strong&gt; posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Name&lt;/strong&gt;, której można użyć jeżeli chcemy stworzyć swój własny magazyn.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Poniższy fragment kodu demonstruje jak użyć klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X509Store&lt;/strong&gt; aby pokazać informacje o certyfikatach głównych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X509Certificates&lt;/strong&gt; zainstalowanych na maszynie lokalnej:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;CertificateTest&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        X509Store store = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; X509Store(StoreName.Root,&lt;br /&gt;            StoreLocation.LocalMachine);&lt;br /&gt;        store.Open(OpenFlags.ReadOnly);&lt;br /&gt;&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Friendly Name\t\t\t\t\t Expiration date"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (X509Certificate2 certificate &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; store.Certificates) {&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0}\t{1}"&lt;/span&gt;, certificate.FriendlyName&lt;br /&gt;                , certificate.NotAfter);&lt;br /&gt;        }&lt;br /&gt;        store.Close();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Zarządzanie kluczami&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Czasami chcemy aby nasze dane były po prostu zabezpieczone bez zastanawiania się nad rodzajem algorytmu lub sposobie implementacji. Przykładowo aby algorytm szyfrowania był efektywny trzeba chronić wspólne hasło dla algorytmu symetrycznego i klucz prywatny dla algorytmu asynchronicznego. &lt;br /&gt;Aby rozwiązać tego typu problemy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; oferuje przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Cryptography&lt;/strong&gt; i klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProtectedData&lt;/strong&gt;. Ta klasa posiada dwie metody statyczne: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Protect&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Unprotect&lt;/strong&gt;. Ich sygnatury są następujące:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] Protect(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] userData,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] optionalEntropy,&lt;br /&gt;    DataProtectionScope &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;scope&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] Unprotect(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] encryptedData,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] optionalEntropy,&lt;br /&gt;    DataProtectionScope &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;scope&lt;/span&gt;&lt;br /&gt;)&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pierwszym parametrem są dane do zaszyfrowania lub odszyfrowania. Drugim parametrem jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;optionalEntropy&lt;/em&gt; używany do zwiększenia złożoności zaszyfrowanych danych. trzecim jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataProtectionScope&lt;/strong&gt;, określa on, kto może odszyfrować dane. Jego wartości to&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataProtectionScope.CurrentUser&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataProtectionScope.LocalMachine&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu demonstruje użycie klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProtectedData&lt;/strong&gt; do zaszyfrowania ciągu znaków, które odszyfrować może tylko aktualny użytkownik.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte[] &lt;/span&gt;ProtectString(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string &lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;data&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte[] &lt;/span&gt;userData = System&lt;span style="box-sizing: border-box; outline: none !important;"&gt;.Text&lt;/span&gt;.Encoding.Default.GetBytes(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;data&lt;/span&gt;)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte[] &lt;/span&gt;encryptedData = ProtectedData.Protect(userData, null,&lt;br /&gt;        DataProtectionScope.CurrentUser)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    return encryptedData&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Jaki algorytm wybrać&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Firma &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; rekomenduje następujące algorytmy do użycia w następujących sytuacjach:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dla prywatności danych algorytm &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Aes&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dla integralności danych algorytm &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HMACSHA256&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HMACSHA512&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do cyfrowego podpisu algorytmy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RSA&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDsa&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do wymiany kluczy algorytmy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RSA&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ECDiffieHellman&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do generowania losowych liczb klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RNGCryptoServiceProvider&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do generowania klucza z hasła &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rfc2898DeriveBytes&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu zawiera pełny przykład użycia algorytmu asymetrycznego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RSA&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Security.Cryptography;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;namespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Encryption.Asymmetric&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;RSASample&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Run&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; keyContainerName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"MyKeyContainer"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; clearText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is the data we want to encrypt!"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; cspParams = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CspParameters();&lt;br /&gt;            cspParams.KeyContainerName = keyContainerName;&lt;br /&gt;&lt;br /&gt;            RSAParameters publicKey;&lt;br /&gt;            RSAParameters privateKey;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; rsa = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; RSACryptoServiceProvider(cspParams)) {&lt;br /&gt;&lt;br /&gt;                rsa.PersistKeyInCsp = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;                publicKey = rsa.ExportParameters(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;);&lt;br /&gt;                privateKey = rsa.ExportParameters(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;                rsa.Clear();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] encrypted = EncryptUsingRSAParam(clearText, publicKey);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; decrypted = DecryptUsingRSAParam(encrypted, privateKey);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Asymmetric RSA"&lt;/span&gt;);&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Asymmetric RSA - Using RSA Params"&lt;/span&gt;);&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Encrypted:{0}"&lt;/span&gt;, Convert.ToBase64String(encrypted));&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Decrypted:{0}"&lt;/span&gt;, decrypted);&lt;br /&gt;            Console.WriteLine();&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Asymmetric RSA - Using Persistent Key Container"&lt;/span&gt;);&lt;br /&gt;            encrypted = EncryptUsingContainer(clearText, keyContainerName);&lt;br /&gt;            decrypted = DecryptUsingContainer(encrypted, keyContainerName);&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Encrypted:{0}"&lt;/span&gt;, Convert.ToBase64String(encrypted));&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Decrypted:{0}"&lt;/span&gt;, decrypted);&lt;br /&gt;            Console.WriteLine();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] EncryptUsingRSAParam(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;, RSAParameters rsaKeyInfo)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; rsa = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; RSACryptoServiceProvider())&lt;br /&gt;            {&lt;br /&gt;                rsa.ImportParameters(rsaKeyInfo);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] encodedData = Encoding.Default.GetBytes(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] encryptedData = rsa.Encrypt(encodedData, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;                rsa.Clear();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; encryptedData;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DecryptUsingRSAParam&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;byte&lt;/span&gt;[] encryptedData, RSAParameters rsaKeyInfo&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; rsa = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; RSACryptoServiceProvider())&lt;br /&gt;            {&lt;br /&gt;                rsa.ImportParameters(rsaKeyInfo);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] decryptedData = rsa.Decrypt(encryptedData, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; decryptedValue = Encoding.Default.GetString(decryptedData);&lt;br /&gt;&lt;br /&gt;                rsa.Clear();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; decryptedValue;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] EncryptUsingContainer(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; containerName)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; cspParams = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CspParameters();&lt;br /&gt;            cspParams.KeyContainerName = containerName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; rsa = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; RSACryptoServiceProvider(cspParams))&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] encodedData = System.Text.Encoding.Default.GetBytes(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] encryptedData = rsa.Encrypt(encodedData, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;                rsa.Clear();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; encryptedData;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DecryptUsingContainer&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;byte&lt;/span&gt;[] encryptedData, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; containerName&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; cspParams = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CspParameters();&lt;br /&gt;            cspParams.KeyContainerName = containerName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; rsa = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; RSACryptoServiceProvider(cspParams))&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] decryptedData = rsa.Decrypt(encryptedData, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; decryptedValue = Encoding.Default.GetString(decryptedData);&lt;br /&gt;&lt;br /&gt;                rsa.Clear();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; decryptedValue;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Zarządzanie assembly&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynikiem kompilacji projektu są pliki wykonywalne, nazywane &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;assembly&lt;/strong&gt;. Assembly są blokami budującymi każdą aplikację &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt;. Są one podstawową jednostką do wdrożenia, wersjonowania, ponownego użycia i bezpieczeństwa.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Assembly zawiera &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Intermediate Language (IL)&lt;/em&gt;, metadane i zasoby. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IL&lt;/em&gt; jest rezultatem kompilacji kodu źródłowego, który może być zrozumiany przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Common Language Runtime (CLR)&lt;/em&gt;. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt; posiada komponent kompilatora &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Just In Time (JIT)&lt;/em&gt;, który kompiluje kod &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IL&lt;/em&gt; do kodu binarnego który może być uruchomiony na wybranej platformie, np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows&lt;/em&gt;. Assembly może składać się z jednego lub wielu plików. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; generuje tylko assembly jedno plikowe.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Assembly jest otrzymywane przez kompilację projektu. Wynikiem assembly może być plik procesowy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;EXE&lt;/em&gt; lub plik biblioteki &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DLL&lt;/em&gt;. Różnicą pomiędzy tymi dwoma jest obecność głównego punktu wejścia w plikach procesowych czyli metody która jest uruchamiana kiedy aplikacja startuje np metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wersja Assembly&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Oprogramowanie ewoluuje i sposobem na oznaczenie tego jest tworzenie nowych wersji, gdzie każda nowa wersja dodaje nowe funkcje, naprawia błędy lub jest kompletnie przepisana. &lt;br /&gt;Wersja assembly w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; jest zaimplementowana jako ciąg znaków, zwykle składająca się z czterech części numerycznych odseparowanych kropkami: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Major&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Minor&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Build&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Revision&lt;/strong&gt;. Przykładowo wszystkie assembly w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework 4.5&lt;/em&gt; posiadają wersję 4.0.30319.17929. &lt;br /&gt;Oznaczenia części z których składa się wersja:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Revision&lt;/strong&gt; - jest zwykle losowym numerem rozróżniającym wersje o tym samym numerze &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Build&lt;/strong&gt;. Zwykle zmienia się ją przy każdym budowaniu projektu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Build&lt;/strong&gt; - jest to zwykle numer który wzrasta każdego dnia, kiedy pracujemy nad aktualną wersją produktu. Zwykle numer zmieniany jest każdej nocy przez nocny proces budowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Minor&lt;/strong&gt; - numer ten jest zwiększany z każdym publicznym wydaniem produktu. Zwykle dwie wersje tego samego produktu które są kompatybilne wstecz mają ten sam numer &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Major&lt;/strong&gt; lecz różnią się właśnie numerem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Minor&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Major&lt;/strong&gt; - numer zwiększany za każdym razem, gdy masz główne wydanie swojego produktu, albo przez zmianę istniejących funkcji lub przepisywanie całej aplikacji.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;Wersję aplikacji można zmieniać na dwa sposoby. Pierwszym jest zmiana wersji w oknie właściwości projektu. W oknie właściwości Assembly naciskamy guzik &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Assembly Information&lt;/em&gt; i pojawia się okno dialogowe w którym mozna ustawić numer wersji podobne do poniższego:&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;&lt;a rel="attachment wp-att-664" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1458070981360.png"&gt;&lt;img class="aligncenter size-medium wp-image-664" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1458070981360-300x300.png" alt="1458070981360" width="300" height="300" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Drugim sposobem jest edycja wersji w pliku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;AssemblyInfo.cs&lt;/em&gt; który znajduje się w folderze &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Properties&lt;/em&gt; każdego projektu. Na końcu pliku można znaleźć linię z wersją projektu przypominającą poniższą linię:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[assembly: &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;AssemblyVersion&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"2.1.42.15"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;]&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Assembly Version&lt;/em&gt; jest ignorowana przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt;, chyba że jest ona używana wraz z silnymi nazwami.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Podpisywanie assembly używając silnych nazw&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Problem z plikami &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DLL&lt;/em&gt; pojawia się kiedy wiele aplikacji używa tej samej biblioteki. Jeżeli aplikacje są skompilowane z różnymi wersjami tej samej biblioteki to ta wersja która została zainstalowana najpóźniej nadpisuje pozostałe. Jeżeli występują problemy z kompatybilnością pomiędzy wersjami biblioteki to niektóre aplikacje mogą działać niepoprawnie a nawet nie działać wcale. Biblioteka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; rozwiązała ten problem wprowadzając nowy koncept nazywany &lt;em style="box-sizing: border-box; outline: none !important;"&gt;side-by-side versioning&lt;/em&gt;. Polega to rozróżnieniu pomiędzy różnymi wersjami tej samej biblioteki, przy jednoczesnym zapewnieniu, że dwie różne wersje pochodzą z tego samego źródła. &lt;br /&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; nazwa assembly składa się z czterech części:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Przyjaznej nazwy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wersji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kultury.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;PublicKeyToken&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przyjazna nazwa jest nazwą assembly, zwykle bez rozszerzenia. &lt;br /&gt;Wersja to wersja assembly omówiona w poprzedniej sekcji. &lt;br /&gt;Kultura jest używany, gdy chcemy zlokalizować swoją aplikację na różnych rynkach. Aby zlokalizować aplikację, należy utworzyć jedną assembly zawierającą kod i jedną assembly dla każdego regionu aplikacji. Assembly dla regionów zawierają jedynie zasoby jak np przetłumaczone teksty lub zdjęcia. Assembly wykonywalna posiada zawsze kulturę neutralną.
&lt;div&gt;Aby assembly posiadała silną nazwę należy ją podpisać parą kluczy prywatnego i publicznego. Klucz prywatny jest używany do cyfrowego podpisania assembly a klucz publiczny jest używany do weryfikacji tego podpisu. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Public Key Token&lt;/em&gt; jest 64 bitowym skrótem klucza publicznego assembly. Skrót jest używany aby zaoszczędzić miejsce, ponieważ klucz jest dużo dłuższy.&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;Parę kluczy prywatnego i publicznego dla assembly można wygenerować na dwa sposoby. Pierwszym jest użycie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt;. W oknie właściwości wybieramy zakładkę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Signing&lt;/em&gt; i zaznaczamy pole wyboru &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Sign the Assembly&lt;/em&gt; jak na obrazku poniżej:&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;a rel="attachment wp-att-665" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1458145397514.png"&gt;&lt;img class="aligncenter size-medium wp-image-665" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1458145397514-300x188.png" alt="1458145397514" width="300" height="188" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Wybieramy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;&amp;lt;New...&amp;gt;&lt;/em&gt; i pokaże się okno dialogowe jak poniższe:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;a rel="attachment wp-att-667" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/str_name.png"&gt;&lt;img class="aligncenter size-medium wp-image-667" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/str_name-300x226.png" alt="str_name" width="300" height="226" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;W oknie dialogowym można ustawić nazwę pliku klucza, hasło i algorytm używany do podpisu cyfrowego.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Drugim sposobem generowania kluczy jest użycie programu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;sn.exe&lt;/strong&gt; w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Developer Command Prompt&lt;/em&gt; i użycie komendy:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;sn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.exe&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;-k&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;myFile&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.snk&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Utworzy to nowy klucz który należy wybrać opcją &lt;em style="box-sizing: border-box; outline: none !important;"&gt;&amp;lt;Browse…&amp;gt;&lt;/em&gt; w oknie wyboru klucza.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy assembly będzie wymagała podpisu cyfrowego to kompilator podpiszę assembly używając klucza prywatnego i dołączy klucz publiczny do assembly dla możliwości weryfikacji. następnym krokiem jest utworzenie skrótu dla klucza publicznego aby utworzyć &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Public Key Token&lt;/em&gt; i również dołączyć go do assembly. &lt;br /&gt;Pełna nazwa assembly jest nazywana &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Fully Qualified Name (FQN)&lt;/em&gt;. Przykładowo &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FQN&lt;/em&gt; dla assembly &lt;em style="box-sizing: border-box; outline: none !important;"&gt;System&lt;/em&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.5&lt;/em&gt; to:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Side-by-Side Versioning&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Silne nazwy miałyby tylko niewielką wartość gdyby nie potęga uruchamiania różnych wersji tego samego assembly obok siebie. &lt;br /&gt;Wersionowanie obok siebie działa tylko z silnie nazwanymi assembly ponieważ potrzebuje aby były one wdrożone do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Global Assembly Cache (GAC)&lt;/em&gt;. &lt;br /&gt;Kiedy dodajemy referencję do assembly to informacja o referencji jest dodawana do pliku manifestu assembly. Manifest jest osadzony w assembly jako część metadanych. W pliku manifestu każda referencja jest reprezentowana przez blok przypominający poniższy kod:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Metadata version: v4.0.30319&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.assembly extern mscorlib&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.publickeytoken = (B7 7A 5C 56 19 34 E0 89) // .z\V.4..&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.ver 4:0:0:0&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.assembly extern CommonFunctionality&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.ver 1:0:0:0&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.assembly 'Programming CSharp Assembly'&lt;/span&gt;&lt;br /&gt;{ … }&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pierwsza linia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.assembly extern&lt;/em&gt; reprezentuje referencję do assembly &lt;em style="box-sizing: border-box; outline: none !important;"&gt;mscorlib&lt;/em&gt;, która jest dołączana domyślnie przez wszystkie aplikacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; ponieważ zawiera definicje wszystkich bazowych typów danych. Wersja assembly to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;4:0:0:0&lt;/em&gt; a &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Public Key Token&lt;/em&gt; to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;(B7 7A 5C 56 19 34 E0 89)&lt;/em&gt;. Druga &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.assembly extern&lt;/em&gt; reprezentuje referencję do assembly &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CommonFunctionality&lt;/em&gt; w wersji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;1.0.0.0&lt;/em&gt;, która nie jest podpisana. &lt;br /&gt;Gdyby druga assembly była podpisana to wpis mógłby wyglądać tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; display: block; padding: 0px; margin: 0px 0px 1.1em; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Metadata version: v4.0.30319&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.assembly extern mscorlib&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.ver 4:0:0:0&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.assembly extern CommonFunctionality&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.publickeytoken = (48 27 85 37 58 E3 97 63 ) // H'.7X..c&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.ver 1:0:0:0&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.assembly 'Programming CSharp Assembly'&lt;/span&gt;&lt;br /&gt;{ …}&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;Te informacje można podejrzeć używając narzędzia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Intermediate Language Disassembler (ildasm.exe)&lt;/em&gt; z linii komend &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Developer Command Prompt&lt;/em&gt;. Uruchamiamy ją podając jako parametr ścieżkę i nazwę pliku assembly. Otwiera to okno aplikacji w którym podglądamy manifest:&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;a rel="attachment wp-att-666" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/man.png"&gt;&lt;img class="aligncenter size-medium wp-image-666" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/man-222x300.png" alt="man" width="222" height="300" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Kiedy uruchamiamy aplikację to środowisko uruchomieniowe próbuje zlokalizować wszystkie wymagane assembly. &lt;br /&gt;Jeżeli assembly nie jest podpisane to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt; szuka w lokalnym folderze aplikacji bazując na nazwie assembly ignorując wersję. &lt;br /&gt;Jeżeli assembly jest podpisana to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt; pierw sprawdza czy są jakieś zasady określone dla danego assembly które mogą wskazać, że trzeba użyć innej wersji assembly. Proces zastępowania assembly bez konieczności rekompilacji innych assembly które jej używają nazywa się &lt;em style="box-sizing: border-box; outline: none !important;"&gt;binding redirection&lt;/em&gt;. Kiedy wersja jest ustalona, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt; pierw przeszukuje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;GAC&lt;/em&gt; w poszukiwaniu określonej wersji assembly, jeżeli tam nie znajdzie to szuka w lokalnym folderze aplikacji. Kiedy znajdzie assembly to sprawdza jej podpis cyfrowy. Jeżeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt; znejdzie assembly ale nie znajdzie odpowiedniej jej wersji lub kiedy podpis się nie zgadza to zgłoszony zostaje wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.IO.FileLoadException&lt;/strong&gt;. Jeżeli assembly nie może być znalezione to zgłoszony zostaje wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.IO.FileNotFoundException&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Od wersji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 2.0&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; dodał do nazwy assembly architekturę procesora, lecz jest ona opcjonalna. Oznacza to, że można mieć dwie takie same wersje assembly rozróżnione atrybutem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProcessorArchitecture&lt;/strong&gt;. &lt;br /&gt;Wartości atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProcessorArchitecture&lt;/strong&gt; są opisane enumeracją &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Reflection.ProcessorArchitecture&lt;/strong&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;None&lt;/strong&gt; - niewymieniona lub nieznana.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MSIL&lt;/strong&gt; - niezależne od procesora.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;x86&lt;/strong&gt; - 32-bitowy procesor Intel.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IA64&lt;/strong&gt; - 64-bitowy procesor Intel.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Amd64&lt;/strong&gt; - 64-bitowy procesor AMD.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Arm&lt;/strong&gt; - procesor ARM.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Architektura procesora jest wyświetlana tylko jeżeli jest różna od &lt;em style="box-sizing: border-box; outline: none !important;"&gt;None&lt;/em&gt;. &lt;br /&gt;Przykładowo jeżeli assembly &lt;em style="box-sizing: border-box; outline: none !important;"&gt;System&lt;/em&gt; miałoby ustawiony atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProcessorArchitecture&lt;/strong&gt; do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MSIL&lt;/strong&gt; to nazwa assembly byłaby następująca:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=MSIL&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Dodawanie assembly do GAC&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli aplikacja nie jest aplikacją &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; i korzysta z bibliotek dołączanych dynamicznie, to poszukuje ich w folderze instalacji aplikacji lub w folderach określonych w zmiennej środowiskowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PATH&lt;/strong&gt;. &lt;br /&gt;Zamiast tego aplikacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; używają &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt;, która jest repozytorium różnych podpisanych assembly i która działa jako pamięć podręczna dla bibliotek współdzielonych. Lokalizacja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;&amp;lt; Your Windows Installation Folder&amp;gt;\assembly&lt;/em&gt;. &lt;br /&gt;Zaletami &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; są: współdzieleni assembly, wersjonowanie obok siebie, sprawdzanie podpisu assembly przed instalacją w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; oraz możliwość do prekompilacji assembly dzięki czemu assembly nie musi być kompilowane przez kompilator &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JIT&lt;/em&gt; za każdym razem gdy jest ładowana. Aby dokonać prekompilacji należy użyć narzędzia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ngen.exe (Native Image Generator)&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Assembly można dodać do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; na dwa sposoby. &lt;br /&gt;Pierwszym jest użycie instalatora. jest to preferowany sposób. Używając instalatora upewniamy się, że instalacja jest atomowa. &lt;br /&gt;Drugim sposobem jest użycie narzędzia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;gacutil.exe&lt;/strong&gt;, które może być użyte w następujący sposób z linii komend:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;gacutil&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.exe&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;[options]&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;[assemblyName | assemblyPath | assemblyListFile]&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej wykorzystywane parametry &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;gacutil.exe&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;/i&lt;/strong&gt; - dodaje assembly do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;/u&lt;/strong&gt; - usuwa assembly do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;/l [assemblyName]&lt;/strong&gt; - wyświetla wszystkie assembly w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt;. Dodanie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;assemblyName&lt;/em&gt; filtruje listę do assembly o określonej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;/r&lt;/strong&gt; - śledzi referencje do assembly poprzez zwiększanie i zmniejszanie licznika w czasie instalacji i deinstalacji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wybór algorytmu szyfrowania&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do szyfrowania danych używanych lokalnie lub jeżeli posiadamy bezpieczny sposób przesyłania klucza szyfrowania to używamy szyfrowania symetrycznego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli nie posiadamy bezpiecznego sposobu przesyłania klucza szyfrowania pomiędzy partnerami to rekomendowane jest szyfrowanie asymetryczne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli wymagana jest tylko integralność danych to należy użyć algorytmu skrótu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli wymagana jest integralność danych i autentyczność należy użyć algorytmu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MAC&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Szyfrowanie symetryczne&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Bazuje na podstawie wspólnego klucza szyfrowania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wymaga wektora inicjującego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IV&lt;/strong&gt;, który nie musi być tajny lecz jest używany do szyfrowania pierwszego bloku danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby go użyć tworzymy instancję obiektu algorytmu symetrycznego po czym wywołujemy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateEncryptor&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateDecryptor&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obiekt szyfrujący lub deszyfrujący jest potem używany z metodą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TransformFinalBlock&lt;/strong&gt; lub poprzez wysłanie do strumienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Szyfrowanie asymetryczne&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Bazuje na podstawie pary komplementarnych kluczy. Dane zaszyfrowane jednym z nich mogą być odszyfrowane jedynie drugim.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeden z kluczy jest nazywany kluczem prywatnym i jest atjny. Drugi z kluczy nazywany jest kluczem publicznym i jest dostępny dla osób szyfrujących dane lub chcących sprawdzić zaszyfrowane dane.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Funkcja skrótu&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Skrót jest procesem mapowania danych binarnych o zmiennej długości na dane binarne określonej długości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;kiedy chcemy mieć pewność, że dane nie zostały zmodyfikowane podczas transportu to możemy strwożyć ich skrót przed wysłaniem i przesłać razem z danymi w celu weryfikacji zgodności.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dwa powszechnie stosowane algorytmy to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA256&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SHA512&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Zarządzanie kluczami&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;klucze symetryczne mogą być wymieniane używając algorytmów asymetrycznych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Asymetryczne klucze prywatne mogą być zabezpieczone używając certyfikatu lub kontenera &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Crypto Service Providers&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wersja assembly&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wersja assembly składa się z czterech części: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Major&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Minor&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Build&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Revision&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Silne nazwy&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Assembly podpisane cyfrowo jest nazywane assembly o silnej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Silna nazwa posiada pięć części: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Friendly Name&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Version&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Culture&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Public Key Token&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Processor Architecture&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GAC&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Rozwinięcie skrótu to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Global Assembly Cache&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; jest repozytorium współdzielonych assembly w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.Net&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; mogą być wdrażane tylko assembly z silną nazwą.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GAC&lt;/strong&gt; może się znajdować więcej niż jedna wersja tej samej assembly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 17 Mar 2016 18:48:25 Z</pubDate>
      <a10:updated>2016-03-17T18:48:25Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1128</guid>
      <link>http://smsoft.pl/blog/x-sprawdzania-poprawnosci-danych-wejsciowych-debugowanie-i-instrumentacja/</link>
      <title>X. Sprawdzania poprawności danych wejściowych, debugowanie i instrumentacja</title>
      <description>&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/h2&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Walidacja&lt;/strong&gt; - sprawdzania poprawności danych wejściowych i użycie wyrażeń regularnych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debugowanie aplikacji&lt;/strong&gt; - tworzenie i użycie dyrektyw procesora, użycie klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt; o podgląd niepożądanych wartości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Diagnostyka&lt;/strong&gt; - użycie narzędzi takich jak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;profiler&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;event log&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;performance counter&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Sprawdzania poprawności danych wejściowych&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższa lista podsumowuje trzy etapy sprawdzania poprawności danych od najczęściej stosowanego i najmniej inwazyjnego do najrzadziej stosowanego i najbardziej inwazyjnego:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Walidacja aktywacji przycisku&lt;/strong&gt; - program może zignorować każdy przycisk który jest nieodpowiedni lecz pozwala na wszystkie które mogą prowadzić do poprawnych danych np znak “-” może rozpoczynać liczbę “-.123”. Opcjonalnie, można oznaczyć pole zawierające niewłaściwą wartość tak aby nie przerywała pracy użytkownika.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Walidacja pola&lt;/strong&gt; - Kiedy przechodzimy z zaznaczeniem do innego pola, program może sprawdzić poprawność jego wartości i oznaczyć niewłaściwą wartość. Program powinien wyświetlać informację, że wartość jest niepoprawna lecz nie powinien wymuszać jej natychmiastowego poprawienia na użytkowniku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Walidacja formularza&lt;/strong&gt; - kiedy użytkownik próbuje zaakceptować cały formularz, program powinien sprawdzić wszystkie jego wartości i wyświetlić wiadomość informującą o zaistniałych błędach jeżeli istnieją. Jest to jedyne miejsce w którym program powinien wymusić poprawienie błędów na użytkowniku. Jest to również miejsce w którym program może sprawdzić poprawność pomiędzy różnymi zależnymi polami.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie funkcji wbudowanych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jedną z najprostszych metod walidacji danych jest sprawdzenie czy użytkownik wprowadził żądaną wartość. Jeżeli wartość byłą wprowadzona w polu tekstowym &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TextBox&lt;/em&gt;, to program może sprawdzić jej długość. &lt;br /&gt;Poniższy fragment kodu sprawdza czy zawartość pola tekstowego jest pusta:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (emailTextBox.Text.Length == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The email field is blank. Display an error message.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dla innych typów kontrolek program musi sprawdzać inne właściwości kontrolki aby dowiedzieć się czy użytkownik dokonał wyboru wartości. Przykładowo dla &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ListBox&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ComboBox&lt;/em&gt; te właściwości to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SelectedIndex&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SelectedItem&lt;/em&gt;. Aby sprawdzić czy użytkownik wybrał wartość należy użyć sprawdzenia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SelectedIndex == -1&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SelectedItem == null&lt;/em&gt;. &lt;br /&gt;Kiedy wartość nie jest pusta, program może sprawdzać dodatkowo czy wartość ma sens. Przykładowo wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;test&lt;/em&gt; nie jest poprawnym adresem e-mail.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Język &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; posiada wbudowane metody służące do sprawdzania poprawności danych wejściowych. Jednymi z najbardziej przydatnych metod są metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryParse&lt;/strong&gt; typów wbudowanych. Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryParse&lt;/strong&gt; próbują parsować ciąg znaków i zwracają &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli im się uda. &lt;br /&gt;Poniższy fragment kodu sprawdza czy pole tekstowe zawiera poprawną wartość waluty:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt; cost;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt;.TryParse(costTextBox.Text,&lt;br /&gt;    NumberStyles.Currency,&lt;br /&gt;    CultureInfo.CurrentCulture,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;out&lt;/span&gt; cost))&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Cost is not a valid currency value. Display an error message.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Enumeracje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NumberStyles&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CultureInfo&lt;/strong&gt; znajdują się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Globalization&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie metod klasy String&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; posiada kilka metod które mogą być użyteczne przy sprawdzaniu poprawności danych wejściowych. &lt;br /&gt;Poniższa lista przedstawia większość użytecznych metod:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Contains&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli ciąg zawiera wybrany podciąg.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EndsWith&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli ciąg jest zakończony wybranym podciągiem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IndexOf&lt;/strong&gt; - zwraca pozycję wybranego podciągu w ciągu, opcjonalnie mozna rozpocząć przeszukiwanie od określonej pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IndexOfAny&lt;/strong&gt; - zwraca pozycję któregokolwiek z wybranych znaków, opcjonalnie mozna rozpocząć przeszukiwanie od określonej pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNullOrEmpty&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli ciąg jest pusty lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNullOrWhitespace&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli ciąg jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;, pusty lub zawiera tylko znaki spacji i tabulacji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LastIndexOf&lt;/strong&gt; - zwraca pozycję ostatniej lokalizacji podciągu w ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LastIndexOfAny&lt;/strong&gt; - zwraca ostatniąpozycję któregokolwiek z wybranych znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Remove&lt;/strong&gt; - usuwa znaki z ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Replace&lt;/strong&gt; - zastępuje podciąg lub znak innym.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Split&lt;/strong&gt; - zwraca tablicę podciągów podzieloną wg wybranego zestawu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StartsWith&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli ciąg rozpoczyna się od wybranego podciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Substring&lt;/strong&gt; - zwraca podciąg na wyznaczonej pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToLower&lt;/strong&gt; - zwraca ciąg z zamienionymi wszystkimi znakami na małe litery.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToUpper&lt;/strong&gt; - zwraca ciąg z zamienionymi wszystkimi znakami na duże litery.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trim&lt;/strong&gt; - zwraca ciąg z usuniętymi białymi znakami na początku i na końcu ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TrimEnd&lt;/strong&gt; - zwraca ciąg z usuniętymi białymi znakami na końcu ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TrimStart&lt;/strong&gt; - zwraca ciąg z usuniętymi białymi znakami na początku ciągu.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie wyrażeń regularnych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia regularne są elastycznym językiem służącym do odnajdywania wzorców w tekście. Wyrażenia regularne pozwalają programowi ustalić czy ciąg znaków pasuje do wzorca, znaleźć fragmenty w tekście które pasują do wzorca i zamienić części ciągu na nowe wartości. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Regex&lt;/strong&gt; z przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Text.RegularExpressions&lt;/strong&gt; służy do pracy z wyrażeniami regularnymi. &lt;br /&gt;Najczęściej używane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Regex&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsMatch&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeśli wyrażenie regularne dopasowuje ciąg.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Match&lt;/strong&gt; - szuka pierwszego wystąpienia podciągu który pasuje do wyrażenia regularnego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Matches&lt;/strong&gt; - zwraca kolekcję z informacjami o wszystkich częściach ciągu które pasują do wyrażenia regularnego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Replace&lt;/strong&gt; - zastępuje niektóre lub wszystkie części ciągu które pasują do wyrażenia regularnego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Split&lt;/strong&gt; - dzieli ciąg do tablicy podciągów oddzielonych tekstem pasującym do wyrażenia regularnego.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Większość tych metod posiada przeciążone wersje. Większość z nich pobiera ciąg jako parametr i może opcjonalnie pobrać drugi parametr którym jest wyrażenie regularne. Jeżeli nie użyjemy parametru z wyrażeniem regularnym to zostanie użyte wyrażenie które podaliśmy w konstruktorze. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Regex&lt;/strong&gt; posiada również statyczną wersję tych metod które zawsze pobierają ciąg i wyrażenie regularne jako parametry.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia regularne są kombinacją literałów i znaków które mają specjalne znaczenie. Przykładowo sekwencja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;[a-z]&lt;/em&gt; oznacza, że obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Regex&lt;/strong&gt; powinien dopasować każdy pojedynczy znak z zakresu od “a” do “z”. &lt;br /&gt;Wyrażenia regularne mogą zawierać również sekwencje znaków specjalnych zwanych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;escape sequences&lt;/em&gt; które reprezentują pewne specjalne wartości. Przykładowo sekwencja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\b&lt;/strong&gt; oznacza granicę wyrazu a &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\d&lt;/strong&gt; oznacza jakąkolwiek cyfrę. &lt;br /&gt;Czasami program musi użyć znaku nawet jeżeli wygląda on jak znak specjalny. Przykładowo znak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[&lt;/strong&gt; zwykle oznacza rozpoczęcie zakresu znaków. Jeżeli chcemy użyć dokładnie znaku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[&lt;/strong&gt; musimy dołożyć do niego znak ucieczki jaki jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;** czyli użyć sekwencji &lt;/strong&gt;[**.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Ucieczki znakowe&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej wykorzystywanych znaków ucieczki:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\t&lt;/strong&gt; - dopasowuje tabulację.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\n&lt;/strong&gt; - dopasowuje nową linię.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\nnn&lt;/strong&gt; - dopasowuje znak z kodem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ASCII&lt;/em&gt; podanym jako dwie lub trzy cyfry ósemkowe &lt;em style="box-sizing: border-box; outline: none !important;"&gt;nnn&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\xnn&lt;/strong&gt; - dopasowuje znak z kodem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ASCII&lt;/em&gt; podanym jako dwie lub trzy cyfry szesnastkowe &lt;em style="box-sizing: border-box; outline: none !important;"&gt;nnn&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\unnn&lt;/strong&gt; - dopasowuje znak z kodem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ASCII&lt;/em&gt; podanym jako cztery cyfry szesnastkowe &lt;em style="box-sizing: border-box; outline: none !important;"&gt;nnnn&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Klasy znaków&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej wykorzystywanych klas znaków:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[chars]&lt;/strong&gt; - dopasowuje znak do znaków w nawiasie, np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;[aeiou]&lt;/em&gt; dopasowuje małą pojedynczą samogłoskę.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[^chars]&lt;/strong&gt; - dopasowuje pojedynczy znak do znaków które nie są w nawiasie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[first-last]&lt;/strong&gt; - dopasowuje znak do zakresu znaków w nawiasie, np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;[a-zA-Z]&lt;/em&gt; dopasowuje jakąkolwiek literę.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.&lt;/strong&gt; - znak wieloznaczny, który dopasowuje dowolny pojedynczy znak z wyjątkiem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\n&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\w&lt;/strong&gt; - ekwiwalent &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[a-zA-Z_0-9]&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\W&lt;/strong&gt; - ekwiwalent &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[^a-zA-Z_0-9]&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\s&lt;/strong&gt; - dopasowuje pojedynczy biały znak.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\S&lt;/strong&gt; - dopasowuje dowolny pojedynczy znak który nie jest białym znakiem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\d&lt;/strong&gt; - ekwiwalent &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[0-9]&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\D&lt;/strong&gt; - ekwiwalent &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[^0-9]&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Kotwice&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kotwice reprezentują stan ciągu znaków. Lista najczęściej wykorzystywanych kotwic:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;^&lt;/strong&gt; - dopasowuje początek linii lub ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$&lt;/strong&gt; - dopasowuje koniec linii lub ciągu znaków albo przed &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\n&lt;/strong&gt; na końcu linii lub ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\A&lt;/strong&gt; - dopasowuje początek ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\z&lt;/strong&gt; - dopasowuje koniec ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\Z&lt;/strong&gt; - dopasowuje koniec ciągu znaków lub przed &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\n&lt;/strong&gt; na końcu ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\G&lt;/strong&gt; - dopasowuje koniec poprzedniego dopasowania.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Konstrukcje grupujące&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konstrukcje grupujące pozwalają na zdefiniowanie grup dopasowanych fragmentów ciągu. Przykładowo w numerze telefonu 234-567-8901 można zdefiniować grupy przechowujące części 234, 567 i 8901. Program może później użyć tych grup w kodzie lub w tym samym wyrażeniu regularnym. &lt;br /&gt;Najczęściej wykorzystywanymi rodzajami grup są grupy numerowane i nazwane. &lt;br /&gt;Aby utworzyć grupę numerowaną należy zamknąć wyrażenie regularne w nawiasie okrągłym i nadać numer grupie zaczynając od 1, np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(\w)\1&lt;/strong&gt;. &lt;br /&gt;Aby utworzyć grupę nazwaną należy użyć składni &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(?subexpression)&lt;/strong&gt;, np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(?\w)&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Kwantyfikatory&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kwantyfikatory pozwalają na dopasowanie poprzedniego elementu określoną ilość razy, np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\d{3}&lt;/strong&gt; dopasowuje jakąkolwiek cyfrę trzy razy. Lista najczęściej wykorzystywanych kwantyfikatorów:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;*&lt;/strong&gt; - dopasowuje poprzedni element 0 lub więcej razy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;+&lt;/strong&gt; - dopasowuje poprzedni element 1 lub więcej razy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;?&lt;/strong&gt; - dopasowuje poprzedni element 0 lub 1 raz.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;{n}&lt;/strong&gt; - dopasowuje poprzedni element &lt;em style="box-sizing: border-box; outline: none !important;"&gt;n&lt;/em&gt; razy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;{n,}&lt;/strong&gt; - dopasowuje poprzedni element &lt;em style="box-sizing: border-box; outline: none !important;"&gt;n&lt;/em&gt; lub więcej razy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;{n,m}&lt;/strong&gt; - dopasowuje poprzedni element od &lt;em style="box-sizing: border-box; outline: none !important;"&gt;n&lt;/em&gt; do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;m&lt;/em&gt; razy.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Przemienność&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przemienność pozwala na użycie znaku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;|&lt;/strong&gt; aby pozwolić na dopasowanie do jednego z dwóch wyrażeń, np wyrażenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(yes|no)&lt;/strong&gt; dopasowuje albo &lt;em style="box-sizing: border-box; outline: none !important;"&gt;yes&lt;/em&gt; alno &lt;em style="box-sizing: border-box; outline: none !important;"&gt;no&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Opcje wyrażeń regularnych&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Program może ustawić opcje wyrażeń regularnych na trzy sposoby. &lt;br /&gt;Pierwszym jest użycie dodatkowego parametru w metodzie obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Regex&lt;/strong&gt;. Parametr jest zdefiniowany jako enumerator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RegexOptions&lt;/strong&gt;. &lt;br /&gt;Drugim sposobem jest użycie składni &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(?options)&lt;/strong&gt; w wyrażeniu regularnym. Znak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;-&lt;/strong&gt; na początku opcji wyłącza wybrane opcje. &lt;br /&gt;Trzecim sposobem jest użycie składni &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(?options:subexpression)&lt;/strong&gt; w wyrażeniu regularnym. Fragment &lt;em style="box-sizing: border-box; outline: none !important;"&gt;subexpression&lt;/em&gt; oznacza część wyrażenia do której opcje mają być zastosowane. &lt;br /&gt;Lista możliwych opcji:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;i&lt;/strong&gt; - ignoruj wielkość liter.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;m&lt;/strong&gt; - wielowierszowy, znaki &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;^&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$&lt;/strong&gt; oznaczają początek i koniec linii.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;s&lt;/strong&gt; - jedna linia, znak &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.&lt;/em&gt; dopasowuje wszystkie znaki włącznie z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;\n&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;n&lt;/strong&gt; - jawne przechwytywanie, nie przechwytuje grup anonimowych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;x&lt;/strong&gt; - ignoruj białe znaki we wzorcu i pozwala na użycie komentarzy po znaku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy przykład przedstawia wyrażenie regularne testujące czy podany numer jest poprawnym numerem telefonu w USA:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Perform simple validation for a 7-digits US phone number.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;phone7TextBox_TextChanged&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(object sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; pattern = @&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"^\d{3}-\d{4}$"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;bool&lt;/span&gt; valid = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;false&lt;/span&gt;; &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; text = phone7TextBox.Text;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (text.Length == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;) valid = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Regex.IsMatch(text, pattern)) valid = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (valid) phone7TextBox.BackColor = SystemColors.Control;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt; phone7TextBox.BackColor = Color.Yellow;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Integralność Danych&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;To, że dane przeszły walidację nie zawsze oznacza, że są poprawne. Nawet jeżeli użytkownik wprowadził poprawne dane to mogą one zostać uszkodzone przez niepoprawne kalkulacje wykonywane przez system. Dodatkowymi metodami pozwalającymi na uniknięcie tego typu błędów są asercje i walidacja poprawności danych w bazie danych.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie walidacji w bazie danych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli program używa bazy danych to można w niej dodać kontrole i ograniczenia aby nie pozwolić na zapisanie nieprawidłowych danych. &lt;br /&gt;Silniki baz danych potrafią rozpoznać czy wartość jest pusta, posiada odpowiedni format, posiada unikalną wartość oraz potrafią rozpoznać relacje z innymi polami w tym samym lub innym rekordzie.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie asercji&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Innym sposobem na sprawdzenie integralności danych są asercje. Asercje są fragmentami kodu które deklarują pewne twierdzenie na temat danych i sprawdzają czy jest ono prawdziwe. &lt;br /&gt;Jednym ze sposobów stworzenia asercji jest użycie klauzuli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;if&lt;/em&gt; aby przetestować dane i zgłoszenie wyjątku jeżeli dane są niepoprawne, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;if &lt;span style="box-sizing: border-box; outline: none !important;"&gt;(!Regex.IsMatch&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;zip&lt;/span&gt;, @&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"^\d{5}$"&lt;/span&gt;)&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;    throw new FormatException&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ZIP code has an invalid format."&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby tworzyć prościej tego rodzaju asercje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; posiada klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Diagnostic.Debug&lt;/strong&gt;. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; tej klasy testuje warunek i zgłasza wyjątek jeżeli nie jest prawdziwy. Poniższy fragment kodu jest ekwiwalentem poprzedniego z użyciem klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Debug&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Assert&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Regex&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.IsMatch&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;zip&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;@&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;"^\d{5}$"));&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; jest wykonywana tylko trybie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;debug&lt;/em&gt; programu.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Debugowanie&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Środowisko programistyczne &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; posiada narzędzi do interaktywnego debugowania aplikacji. Pułapki oraz podgląd wartości zmiennych za pomocą okna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;watches&lt;/em&gt; oraz zdolność do przechodzenie kodu krok po kroku pozwalają śledzić działanie aplikacji. Pułapki mogą dodatkowo posiadać warunki które musi spełnić kod aby zostały uruchomione, filtry oraz liczniki wykonania.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Dyrektywy procesora&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dyrektywy procesora mówią kompilatorowi języka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; jak ma wykonywać kod. Pozwalają na wykluczenie fragmentu kodu z kompilacji, zdefiniowanie symboli do użycia w zarządzanym kodzie oraz pogrupowanie fragmentów kodu.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista dyrektyw procesora:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#define i #undef&lt;/strong&gt;&lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#define&lt;/strong&gt; definiuje symbol procesora lub warunkowy symbol kompilacji dla modułu który zawiera dyrektywę. Później można użyć dyrektyw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#if&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#elif&lt;/strong&gt; aby sprawdzić czy symbol został zdefiniowany. &lt;br /&gt;Do symbolu nie można przypisać wartości. Można jedynie zdefiniować lub usunąć symbol oraz sprawdzić czy został zdefiniowany. &lt;br /&gt;Można również użyć &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; aby zdefiniowało symbole dla całego projektu. Aby tego dokonać we właściwościach projektu w zakładce &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Build&lt;/em&gt; definiujemy wybrane symbole w polu tekstowym &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Conditional Compilation Symbols&lt;/em&gt;. &lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#undef&lt;/strong&gt; usuwa symbol. &lt;br /&gt;Obie dyrektywy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#define&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#undef&lt;/strong&gt; mogą być używane jedynie na początku pliku więc dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#undef&lt;/strong&gt; praktycznie służy tylko do usunięcia symboli zdefiniowanych na poziomie projektu.&lt;/p&gt;
&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#if&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#elif&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#else&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#endif&lt;/strong&gt;&lt;br /&gt;Dyrektywy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#if&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#elif&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#else&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#endif&lt;/strong&gt; działają jak instrukcje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;if&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;else&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;else if&lt;/em&gt; języka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; lecz testują istnienie symboli procesora a nie wyrażenia logiczne. &lt;br /&gt;Dyrektywy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#if&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#elif&lt;/strong&gt; testują czy symbol został zdefiniowany. Jeżeli tak to kod który zawierają zostaje dołączony do kompilacji, jeżeli symbol nie istnieje to kod zostaje wyłączony z kompilacji. &lt;br /&gt;Kod dyrektywy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#else&lt;/strong&gt; jest włączony do kompilacji jeżeli żaden z symboli z dyrektyw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#if&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#elif&lt;/strong&gt; nie został zdefiniowany. &lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#endif&lt;/strong&gt; kończy blok dyrektyw, np:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Debug levels. Level 2 gives the most information.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;define&lt;/span&gt; DEBUG1&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//#define DEBUG2&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;VerifyInternetConnections&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; DEBUG2&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display lots of debugging information.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;elif&lt;/span&gt; DEBUG1&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display some debugging information.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display minimal debugging information.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;endif&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Verify the connections.&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można również testować równoczesne istnienie kilku symboli używając operatorów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;!=&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;==&lt;/strong&gt; oraz nawiasów jeżeli konieczna jest kolejność, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; DEBUG1 == DEBUG2&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wartości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; oraz &lt;em style="box-sizing: border-box; outline: none !important;"&gt;false&lt;/em&gt; mogą być uzyte do reprezentowania istnienia symboli, poniższe trzy wyrażenia są sobie równoważne:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; DEBUG1&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; DEBUG1 == true&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; DEBUG1 != false&lt;/span&gt;&lt;/pre&gt;
&lt;ol start="3" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#warning i #error&lt;/strong&gt;&lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#warning&lt;/strong&gt; generuje ostrzeżenie które wyświetla się w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Error List&lt;/em&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt;. Edytor kodu podkreśla ostrzeżenie falowaną zieloną linią. &lt;br /&gt;Przykładowym użyciem jest oznaczenie kodu który jest przestarzały, np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; OLD_METHOD&lt;br /&gt;#warning &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Using&lt;/span&gt; obsolete &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;method&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;to&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;calculate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;fees&lt;/span&gt;.&lt;br /&gt;//...&lt;br /&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;else&lt;/span&gt;&lt;br /&gt;//...&lt;br /&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;endif&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#error&lt;/strong&gt; jest podobna do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#warning&lt;/strong&gt; z tą różnicą, że zamiast ostrzeżenia generuje błąd i nie pozwala na poprawne zbudowanie projektu. Edytor w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; podkreśla błąd czerwoną falowaną linią.&lt;/p&gt;
&lt;ol start="4" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#line&lt;/strong&gt;&lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#line&lt;/strong&gt; pozwala zmienić numer linii w programie oraz opcjonalnie nazwę pliku która jest opisana w oknie ostrzeżeń, błędów i stosu. &lt;br /&gt;Poniższy fragment kodu wyświetla śledzenie stosu ze zmienionym numerem linii i nazwą pliku:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#line 10000 "Geometry Methods"&lt;/span&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"********** "&lt;/span&gt; + Environment.StackTrace);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#line default&lt;/strong&gt; przywraca linię zmienioną wcześniej przez dyrektywę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#line&lt;/strong&gt;. &lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#line hidden&lt;/strong&gt; ukrywa linię przed debuggerem.&lt;/p&gt;
&lt;ol start="5" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#region i #endregion&lt;/strong&gt;&lt;br /&gt;Dyrektywy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#region&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#endregion&lt;/strong&gt; tworzą nazwany region w kodzie który może być zwijany i rozwijany. Nazwa regionu nie jest obowiązkowa, np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;region&lt;/span&gt; Sales Routines&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Sales routines go here...&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;endregion&lt;/span&gt; Sales Routines&lt;/span&gt;&lt;/pre&gt;
&lt;ol start="6" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma warning&lt;/strong&gt;&lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma&lt;/strong&gt; daje specjalną instrukcję kompilatorowi, potencjalnie umożliwiając tworzenie nowych instrukcji preprocesora. Język &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; pozwala na użycie dyrektyw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma warning&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma checksum&lt;/strong&gt;&lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma warning&lt;/strong&gt; może włączyć i wyłączyć konkretne ostrzeżenie. Rozważmy następujący fragment kodu:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; OrderItem&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; Description;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Quantity = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; decimal UnitPrice = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pole &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Description&lt;/em&gt; nie zostało zainicjowane i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; w czasie budowania projektu zgłosi następujące ostrzeżenie:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Field ‘Description’ is never assigned to, and will always have its default value null.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu pozwala na pominięcie tego ostrzeżenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; OrderItem&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;pragma&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;warning&lt;/span&gt; disable &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0649&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; Description;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;pragma&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;warning&lt;/span&gt; restore &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0649&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Quantity = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; decimal UnitPrice = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;ol start="7" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma checksum&lt;/strong&gt;&lt;br /&gt;Dyrektywa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#pragma checksum&lt;/strong&gt; generuje sumę kontrolną dla pliku, np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;#&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;pragma&lt;/span&gt; checksum &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"filename"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{guid}"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"bytes"&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Debug i Trace&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt; świadczą usługi, które wysyłają wiadomości do obiektów słuchacza. Domyślnie jedynym słuchaczem jest instancja klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefaultTraceListener&lt;/strong&gt; która wysyła wiadomości do okna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Output&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; jest ignorowana w wydaniach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;release&lt;/em&gt;. Dzieje się tak ponieważ do budowania projektu w wersji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;debug&lt;/em&gt; dodawany jest symbol &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DEBUG&lt;/strong&gt; a w wersjach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;release&lt;/em&gt; nie. To domyślne zachowanie można zmienić we właściwościach budowania projektu. Można również stworzyć własne wersje budowania projektu które mogą również zawierać symbol &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DEBUG&lt;/strong&gt;. &lt;br /&gt;Można również użyć dyrektyw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#define&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;#undef&lt;/strong&gt; aby zdefiniować symbol &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DEBUG&lt;/strong&gt;. Przykładowo można zdefiniować symbol &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DEBUG&lt;/strong&gt; w wybranym module aby móc użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug.Assert&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt; która jest również zdefiniowana w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Diagnostic&lt;/strong&gt;, jest podobna do klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; z tą różnicą, że jest kontrolowana przez symbol &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TRACE&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt; posiadają wiele wspólnych metod. Poniżej lista najważniejszych z nich:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; - sprawdza warunek logiczny i zgłasza wyjątek jeżeli jest fałszywy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Fail&lt;/strong&gt; - emituje wiadomość błędu do obiektów nasłuchujących. Efekt jest podobny wyjątku zgłaszanego przez metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Flush&lt;/strong&gt; - opróżnia wyjście do słuchaczy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Indent&lt;/strong&gt; - zwiększenie poziomu wcięcia o 1. pomaga to formatować wysyłane wiadomości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Unindent&lt;/strong&gt; - zmniejsza poziomu wcięcia o 1.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; - zapisuje wiadomość do obiektów nasłuchujących.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteIf&lt;/strong&gt; - zapisuje wiadomość do obiektów nasłuchujących jeżeli spełniony jest wyznaczony warunek logiczny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteLine&lt;/strong&gt; - zapisuje wiadomość do obiektów nasłuchujących i dodaje nową linię.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteLineIf&lt;/strong&gt; - jeżeli spełniony jest wyznaczony warunek logiczny to zapisuje wiadomość do obiektów nasłuchujących i dodaje nową linię.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Listeners&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt; posiadają kolekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Listeners&lt;/strong&gt; w których znajduja się referencje do obiektów nasłuchujących. Domyślnie te kolekcje inicjowane są referencją do obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefaultTraceListener&lt;/strong&gt;. &lt;br /&gt;Aby skierować wyjście do innych lokalizacji należy dodać obiekt nasłuchu do kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Listeners&lt;/strong&gt;. Lista niektórych innych klas nasłuchu których można użyć:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConsoleTraceListener&lt;/strong&gt; - kieruje wyjście do okna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventLogTraceListener&lt;/strong&gt; - kieruje wyjście do dziennika zdarzeń.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriterTraceListener&lt;/strong&gt; - kieruje wyjście do strumienia np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileStream&lt;/strong&gt;. Pozwala to na zapis do dowolnego pliku.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu pokazuje jak stworzyć &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriterTraceListener&lt;/strong&gt; aby skierować wyjście do pliku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TraceFile.txt&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.IO;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Diagnostics;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_Load&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Create the trace output file.&lt;/span&gt;&lt;br /&gt;    Stream traceStream = File.Create(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"TraceFile.txt"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Create a TextWriterTraceListener for the trace output file.&lt;/span&gt;&lt;br /&gt;    TextWriterTraceListener traceListener =&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; TextWriterTraceListener(traceStream);&lt;br /&gt;    Trace.Listeners.Add(traceListener);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Write a startup note into the trace file.&lt;/span&gt;&lt;br /&gt;    Trace.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Trace started "&lt;/span&gt; + DateTime.Now.ToString());&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W czasie działania można dodawać wiadomości przez obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt;. Poniższy fragment kodu pokazuje jak dodawać informacje podczas przetwarzania zamówienia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; processOrderButton_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Log an order processing message.&lt;/span&gt;&lt;br /&gt;    Trace.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Processing order"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Log the order's data.&lt;/span&gt;&lt;br /&gt;    Trace.Indent();&lt;br /&gt;    Trace.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CustomerId: "&lt;/span&gt; + CustomerId);&lt;br /&gt;    Trace.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"OrderId: "&lt;/span&gt; + OrderId);&lt;br /&gt;    Trace.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"OrderItems:"&lt;/span&gt;);&lt;br /&gt;    Trace.Indent();&lt;br /&gt;    foreach (OrderItem item in OrderItems)&lt;br /&gt;        Trace.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(item.ToString());&lt;br /&gt;    Trace.Unindent();&lt;br /&gt;    Trace.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ShippingAddress: "&lt;/span&gt; + ShippingAddress);&lt;br /&gt;    Trace.Unindent();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Process the order.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy program dobiega końca może opróżnić buforowany tekst do pliku:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_FormClosing&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, FormClosingEventArgs e&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Flush the trace output.&lt;/span&gt;&lt;br /&gt;    Trace.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Trace stopped "&lt;/span&gt; + DateTime.Now.ToString());&lt;br /&gt;    Trace.Flush();&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Programowanie plików bazy danych debugowania&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy budujemy projekt w trybie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;bebug&lt;/em&gt; to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; tworzy plik bazy danych programu zawierający informacje o programie potrzebne do debugowania. &lt;br /&gt;Aby kontrolować ilość informacji którą &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VS&lt;/em&gt; dodaje do pliku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PDB&lt;/strong&gt; należy użyć właściwości projektu. W zakładce &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Build&lt;/em&gt; wybieramy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Advanced Build Settings&lt;/em&gt; i wybieramy z listy rozwijanej wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;full&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;pdb-only&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;none&lt;/em&gt;. &lt;br /&gt;Domyślnie wybrana jest opcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;full&lt;/em&gt; tworząca w pełni debugowany program. Opcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;pdb-only&lt;/em&gt; jest domyślna dla trybu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;release&lt;/em&gt; która potrafi wskazać gdzie wystąpiły wyjątki. Opcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;none&lt;/em&gt; sprawia, że &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VS&lt;/em&gt; nie tworzy pliku bazy danych.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Instrumentacja aplikacji&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Instrumentacja aplikacji oznacza dodanie do aplikacji funkcjonalności umożliwiających jej analizowanie. Zwykle jest to dodanie monitorowania wydajności, zapisu błędów i śledzenia wykonywania programu. Dzięki dobrej instrumentacji można zidentyfikować wąskie gardła w aplikacji bez krokowego śledzenia jej przebiegu za pomocą debugera.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Tracing&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Tracing&lt;/strong&gt; jest procesem instrumentacji programu polegającym na śledzeniu co jest wykonywane w aplikacji. Zwykle śledzenie odbywa się z pomocą klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt;. Dodatkowo do zapisywanych informacji można dodać czas i datę wykonywania aby można było zbadać jak program zachowuje sie w różnym czasie.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Event Logs&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Logowanie jest procesem instrumentacji programu polegającym na zapisywaniu kluczowych zdarzeń do dziennika. &lt;br /&gt;Zapis do dziennika zdarzeń może odbywać się na różne sposoby. Można użyć klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Debug&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trace&lt;/strong&gt;, choć ich przeznaczeniem jest raczej śledzenie. Można użyć zapisu do plik w odpowiednich sekcjach. Można użyć zewnętrznej biblioteki jak &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Log4Net&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NLog&lt;/em&gt;. Można również zapisywać zdarzenia do dziennikasystemowego. &lt;br /&gt;Poniższy fragment kodu zapisuje zdarzenia do dziennika systemowego:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Diagnostics;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Write an event log entry.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;writeButton_Click&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(object sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; source = sourceTextBox.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;log&lt;/span&gt; = logTextBox.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; message = eventTextBox.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; id = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;.Parse(idTextBox.Text);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Create the source if necessary. (Requires admin privileges.)&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!EventLog.SourceExists(source))&lt;br /&gt;        EventLog.CreateEventSource(source, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;log&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Write the log entry.&lt;/span&gt;&lt;br /&gt;    EventLog.WriteEntry(source, message,&lt;br /&gt;        EventLogEntryType.Information, id);&lt;br /&gt;    MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"OK"&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zwykle użyteczna jest możliwość konfiguracji ilości logowanych zdarzeń. Pozwala to na zmniejszenie ilości zapisywanych informacji w środowiskach produkcyjnych aby zapis do dziennika nie wpływał na wydajność aplikacji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Profiling&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Profilowanie jest procesem zbierania informacji o programie służącym do późniejszego studiowania jego szybkości, pamięci, użycia zasobów i innych charakterystyk wydajnościowych. Istnieją dwa sposoby profilowania programu, za pomocą profilera lub poprzez instrumentowanie programu ręcznie.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Użycie profilera&lt;/h4&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Automatyczne profilery używają kilku podejść do profilowania aplikacji. Niektóre instrumentują kod źródłowy dodając wyrażenia badające czas do niektórych lub wszystkich metod programu. Inne instrumentują kod skompilowany. Jeszcze inne używają próbkowania CPU. &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; w edycjach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Premium&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Ultimate&lt;/em&gt; posiadają narzędzia służące do badania wydajności aplikacji.
&lt;div&gt;Narzędzia te uruchamiamy wybierając w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VS&lt;/em&gt; z menu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Analyze&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Launch Performance Wizard&lt;/strong&gt;. Okno czarodzieja wygląda tak:&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;a rel="attachment wp-att-652" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1.png"&gt;&lt;img class="aligncenter wp-image-652" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/1.png" alt="1" width="500" height="431" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Opcja próbkowanie CPU cyklicznie sprawdza stan programu aby zobaczyć co jest wykonywane. Pozwala to zdiagnozować które procedury są najbardziej obciążające dla CPU. &lt;br /&gt;Opcja instrumentacji może dostarczyć dokładniejszych informacji lecz dodaje instrumentacje do skopmilowanego kodu co może spowolnić działanie aplikacji. &lt;br /&gt;Opcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Memory Allocation&lt;/em&gt; używa próbkowania do zbierania informacji o uzyciu pamięci. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Opcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Resource Contention Data&lt;/em&gt; jest używana do badania współbieżności w aplikacjach wielowątkowych.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Opcja próbkowania CPU generuje wyniki podobne do poniższych:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;a rel="attachment wp-att-653" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/2.png"&gt;&lt;img class="aligncenter wp-image-653" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/2.png" alt="2" width="500" height="307" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Profilowanie ręczne&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Program można profilować ręcznie poprzez wstawianie do kodu źródłowego fragmentów kodu zapisujących stan aplikacji oraz aktualny czas i czas wykonania. &lt;br /&gt;Poniższy fragment kodu używa klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stopwatch&lt;/strong&gt; do badania czasu wykonania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;PerformCalculations&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    Stopwatch stopwatch = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Stopwatch();&lt;br /&gt;    stopwatch.Start();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Perform the calculations here.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Time: "&lt;/span&gt; +&lt;br /&gt;        stopwatch.Elapsed.TotalSeconds.ToString(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"0.00"&lt;/span&gt;) +&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" seconds"&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Innym sposobem ręcznego profilowania jest użycie liczników wydajności.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Performance Counters&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Liczniki wydajności śledzą system operacyjny, aby dać wyobrażenie o aktywności komputera. &lt;br /&gt;Przykładowo przypuśćmy, że program procesujący zdjęcia skanuje folder w każdej minucie. Jeżeli odnajdzie w folderze zdjęcie, pobiera je, procesuje w jakiś sposób i przenosi do innego folderu. Można użyć liczników wydajności aby śledzić procesowanie każdego pliku. Później można użyć narzędzia systemowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Performance Monitor&lt;/strong&gt; do zobrazowania zmian licznika podczas procesowania programu.&lt;/p&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;Liczniki wydajności można tworzyć za pomocą kodu (więcej na &lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="https://msdn.microsoft.com/library/5e3s61wf.aspx?f=255&amp;amp;amp;MSPPError=-2147217396" target="_blank"&gt;msdn&lt;/a&gt;), lub za pomocą &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt;.&lt;/div&gt;
&lt;div&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VS&lt;/em&gt; otwieramy okno &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Server Explorer&lt;/strong&gt;, rozwijamy drzewo i wybieramy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Performance Counters&lt;/strong&gt; w którego menu kontekstowym dodajemy nową kategorię poprzez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create New Category&lt;/strong&gt;.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;a rel="attachment wp-att-654" href="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/3.png"&gt;&lt;img class="aligncenter wp-image-654" src="http://www.smsoft.pl/blog/wp-content/uploads/2016/03/3-300x228.png" alt="3" width="500" height="380" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;span style="color: #2c3f51;"&gt;&lt;span style="font-size: 15px;"&gt;&lt;span style="font-family: &amp;amp;apos;"&gt;Aby użyc licznika wydajności w programie należy utworzyć obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PerformanceCounter&lt;/strong&gt; z przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Diagnostics&lt;/strong&gt;. Poniższy fragment kodu demonstruje użycie utworzonego na zdjęciu licznika:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; PerformanceCounter totalImages, imagesPerSecond;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_Load&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    totalImages = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; PerformanceCounter();&lt;br /&gt;    totalImages.CategoryName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ImageProcessor"&lt;/span&gt;;&lt;br /&gt;    totalImages.CounterName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Images processed"&lt;/span&gt;;&lt;br /&gt;    totalImages.MachineName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"."&lt;/span&gt;;&lt;br /&gt;    totalImages.ReadOnly = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    imagesPerSecond = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; PerformanceCounter();&lt;br /&gt;    imagesPerSecond.CategoryName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ImageProcessor"&lt;/span&gt;;&lt;br /&gt;    imagesPerSecond.CounterName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Images per second"&lt;/span&gt;;&lt;br /&gt;    imagesPerSecond.MachineName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"."&lt;/span&gt;;&lt;br /&gt;    imagesPerSecond.ReadOnly = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy mamy już utworzony obiekt licznika to program może inkrementować go kiedy wykonywana jest przez nas pożądana akcja. &lt;br /&gt;Załóżmy, że program procesujący zdjęcia skanuje folder cyklicznie sprawdzając czy zawiera zdjęcia. Kiedy znajdzie plik to wywołuje następującą metodę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ProcessImageFile&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; filename)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Process the file.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Increment the performance counters.&lt;/span&gt;&lt;br /&gt;    totalImages.Increment();&lt;br /&gt;    imagesPerSecond.Increment();&lt;br /&gt;}&lt;/pre&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;Aby zobaczyć efekt działania należy uruchomić systemowe narzędzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Performance Monitor&lt;/strong&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Fri, 11 Mar 2016 14:32:25 Z</pubDate>
      <a10:updated>2016-03-11T14:32:25Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1127</guid>
      <link>http://smsoft.pl/blog/ix-praca-z-linq/</link>
      <title>IX. Praca z LINQ</title>
      <description>&lt;p&gt; &lt;/p&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div&gt;&lt;span style="color: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 32px;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Zapytania LINQ&lt;/strong&gt; - pisanie zapytań i metod z użyciem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Manipulowanie danymi za pomocą LINQ&lt;/strong&gt; - manipulowanie danymi za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; a w tym użycie projekcji, użycie złączeń, grupowanie kolekcji, metody agregujące, pobieranie określonej ilości wyników i pomijanie określonej liczby wyników.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Użycie LINQ to XML&lt;/strong&gt; - tworzenie i modyfikacja danych z użyciem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ to XML&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Wyrażenia zapytan LINQ&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Language Integrated Query (LINQ)&lt;/strong&gt; jest aspektem języków w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; który umożliwia użycie ogólnej składni zapytań do wykonywania zapytań na kolekcjach, dokumentach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;, bazach danych oraz wszystkich typach wspierających interfejsy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&amp;lt; T &amp;gt;&lt;/strong&gt; lub&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IQueryable&amp;lt; T &amp;gt;&lt;/strong&gt;. &lt;br /&gt;Istnieją dwa rodzaje składni, które wykonują zapytania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt;. Pierwszym są wyrażenia zapytań. Drugim są zapytania oparte o metody. Dla kompilatora wybór między tymi dwoma metodami jest nieistotny, należy wybrać metodę która bardziej nam odpowiada.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kompilator konwertuje wyrażenia zapytań na zapytania oparte o metody w czasie kompilowania. Wyrażenia zapytań są czasem łatwiejsze do odczytu lecz istnieją operacje których nie można wykonać za pomocą wyrażeń zapytań.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia zapytań szukają w danych zapisanych w tablicy, kolekcji lub jakimkolwiek typie wspierającym interfejsy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&amp;lt; T &amp;gt;&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IQueryable&amp;lt; T &amp;gt;&lt;/strong&gt;. Składnia wyrażeń zapytań jest podobna do języka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zanim powstało &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; do wyszukiwania danych wykorzystywane były pętle. Poniższy przykład demonstruje wyszukanie parzystych liczb w tablicy za pomocą pętli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;foreach&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] evenNumbers = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;];&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; evenIndex = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in myArray)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;        evenNumbers[evenIndex] = i;&lt;br /&gt;        evenIndex++;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia zapytań &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; pozwalają na wykonanie zapytania na kolekcji z użyciem składni podobnej do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt; z tym wyjątkiem, że w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; kolejność wyrażeń jest inna. Korzyścią z użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; jest mniejsza ilość kodu i większa jego czytelność. &lt;br /&gt;Poniższy fragment kodu wykonuje zapytanie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; na tablicy pobierające liczby parzyste:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;var evenNumbers = from i in myArray&lt;br /&gt;    where i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;    select i;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;evenNumbers&lt;/em&gt; została zadeklarowana jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;var&lt;/strong&gt;. Zmienna zdefiniowana jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;var&lt;/strong&gt; jest nazywana zmienną typu niejawnego. Oznacza to, że kompilator określa typ zmiennej bazując na wyrażeniu po prawej stronie instrukcji inicjującej. W tym wypadku kompilator wie, że wartości w zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;evenNumbers&lt;/em&gt; są typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;from&lt;/strong&gt; zawiera &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;i in myArray&lt;/strong&gt;. Kompilator niejawnie wie jakiego typu jest zmienna &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;i&lt;/strong&gt; bazując na type &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;myArray&lt;/strong&gt;. Jest to ekwiwalent instrukcji pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;foreach(int i in myArray)&lt;/strong&gt;. Zmienna &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;i&lt;/strong&gt; reprezentuje wyliczane wartości w tablicy.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W składni &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; pierwszą klauzulą jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;from&lt;/strong&gt;, drugą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; a ostatnią &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt;. W klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; należy używać operatora równoważności (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;==&lt;/strong&gt;).&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt; zwraca zmienną &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;i&lt;/strong&gt;. W tym wypadku oznacza to, że kod wyliczając tablicę powinien zwrócić wszystkie elementy spełniające warunek klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt;. Wykonując kod krokowo można zauważyć, że w momencie wykonywania pętli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;foreach&lt;/em&gt; kod powróci do zapytania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt;. Dzieje się tak ponieważ zapytanie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; nie zostało wykonane do momentu kiedy zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;evenNumbers&lt;/em&gt; została użyta. Nazywa się to wykonaniem odroczonym (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;deferred execution&lt;/em&gt;). Jeżeli podejrzymy zmienną &lt;em style="box-sizing: border-box; outline: none !important;"&gt;evenNumbers&lt;/em&gt; w oknie podglądu w czasie wykonywania to zauważymy, że nie posiada ona wartości i, że jest wykonywana za każdym razem kiedy elementy są wyliczane. Jeżeli źródło danych zostanie zmienione i wyliczymy elementy jeszcze raz to wynik będzie inny, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var evenNumbers = from i in myArray&lt;br /&gt;    where i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;    select i;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;myArray[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;12&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Filtrowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Filtrowanie danych jest dokonywane z użyciem klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; w zapytaniu. Ponieważ używamy języka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; to do złożonych operacji używamy operatorów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;and&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&amp;amp;&lt;/strong&gt;) i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;or&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;||&lt;/strong&gt;). W poprzednim przykładzie klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; zawiera wyrażenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;i % 2 == 0&lt;/strong&gt;. Takie wyrażenie nazywane jest predykatem. Predykat jest wyrażeniem porównującym które jest wykonywane dla każdego elementu w sekwencji. &lt;br /&gt;Poniższy fragment kodu zwraca wszystkie liczby parzyste większe niż pięć z tablicy liczb:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var evenNumbers = from i in myArray&lt;br /&gt;    where i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt; &amp;amp;&amp;amp; i &amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;&lt;br /&gt;    select i;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można napisać wiele klauzul &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; w wyrażeniu zapytania. Oznacza to to samo jakbyśmy mieli wiele wyrażeń w klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; złączonych operatorem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&amp;amp;&lt;/strong&gt;. &lt;br /&gt;Poniższy kod produkuje ten sam wynik co poprzedni:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var evenNumbers = from i in myArray&lt;br /&gt;    where i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;    where i &amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;&lt;br /&gt;    select i;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dla bardziej skomplikowanych warunków wymagających operatorów pierwszeństwa należy użyć nawiasów okrągłych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;()&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Należy zwrócić szczególna uwagę na to, że w wyrażeniu zapytania można użyć wywołania metod. &lt;br /&gt;Poniższy fragment kodu wywołuje metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IsEvenAndGT5&lt;/em&gt; w wyrażeniu zapytania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;RetrieveEvenNumberGT5V3&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;    var evenNumbers = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from i in myArray&lt;br /&gt;        where &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IsEvenAndGT5&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(i)&lt;/span&gt;&lt;br /&gt;        select i&lt;/span&gt;;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(i);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IsEvenAndGT5&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; i)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; (i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt; &amp;amp;&amp;amp; i &amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Sortowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyniki działania zapytania można sortować za pomocą klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;orderby&lt;/strong&gt;. Można sortować rosnąco i malejąco tak jak w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt;. &lt;br /&gt;Poniższy fragment kodu sortuje parzyste wyniki w kolejności malejącej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var evenNumbers = from i in myArray&lt;br /&gt;    where i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;    orderby i descending&lt;br /&gt;    select i;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można również sortować więcej właściwości poprzez oddzielenie ich przecinkiem. &lt;br /&gt;Poniższy fragment kodu sortuje zwracane elementy alfabetycznie wg stanu a potem wg miasta:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Hometown&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; City { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; State { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OrderByStateThenCity&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;Hometown&amp;gt; hometowns = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;Hometown&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Philadelphia"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Trenton"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; orderedHometowns = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; h &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; hometowns&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;orderby&lt;/span&gt; h.State &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ascending&lt;/span&gt;, h.City &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ascending&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; h;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (Hometown hometown &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; orderedHometowns)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(hometown.City + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + hometown.State);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Projekcja&lt;/h3&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt; zwraca obiekty w sekwencji lub zwraca określoną liczbę właściwości obiektu w sekwencji. Pobranie określonej liczby właściwości lub transformacja wyniku do innego typu nazywana jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;projekcją&lt;/strong&gt; wyniku. &lt;br /&gt;Poniższy fragment kodu demonstruje pobranie nazwisk osób z listy obiektów klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Address1 { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; City { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; State { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Zip { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ProjectionV1&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;Person&amp;gt; people = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;Person&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                Address1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"First St"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;                Zip = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19084"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                Address1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Second St"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;, &lt;br /&gt;                Zip = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"08560"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;                Address1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Third St"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ft Washington"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;                Zip = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19034"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; lastNames = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; p &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; people &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; p.LastName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; lastName &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; lastNames)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(lastName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;div style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;
&lt;div&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt; pobiera &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p.LastName&lt;/em&gt; zamiast całego obiektu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p&lt;/em&gt;. Kompilator ustala, że wynikiem powinna być lista typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/em&gt; bazując na typie pobieranej właściwości.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Załóżmy teraz, że potrzebujemy zwrócić imię i nazwisko osób z listy. &lt;br /&gt;Poniższy fragment kodu demonstruje pobranie imion i nazwisk osób z listy obiektów. zapytanie to tworzy typ anonimowy zawierający właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; names = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; p &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; people&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { p.FirstName, p.LastName };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; name &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; names)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(name.FirstName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + name.LastName);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwości typu anonimowego można jawnie nazwać używając poniższej składni:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; names = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; p &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; people&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { First = p.FirstName, Last = p.LastName };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; name &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; names)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(name.First + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + name.Last);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Złączenia&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Do połączenia dwóch lub więcej sekwencji używana jest klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu łączy dwie oddzielne listy po polu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateId&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Employee&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; StateId { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;State&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; StateId { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; StateName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Join&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;        {&lt;br /&gt;            FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;,&lt;br /&gt;            LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;,&lt;br /&gt;            StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;        },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;        {&lt;br /&gt;            FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;,&lt;br /&gt;            LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;,&lt;br /&gt;            StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;&lt;br /&gt;        },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;        {&lt;br /&gt;            FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;,&lt;br /&gt;            LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;,&lt;br /&gt;            StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    List&amp;lt;State&amp;gt; states = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;State&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State()&lt;br /&gt;        {&lt;br /&gt;            StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;,&lt;br /&gt;            StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;        },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State()&lt;br /&gt;        {&lt;br /&gt;            StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;,&lt;br /&gt;            StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeByState = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; e &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employees&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;join&lt;/span&gt; s &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; states&lt;br /&gt;            on e.StateId equals s.StateId&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { e.LastName, s.StateName };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.StateName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt; używa operatora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;equal&lt;/strong&gt; zamiast &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;=&lt;/strong&gt;. Łączone pola mogą być porównywane tylko tym operatorem. Nie można używać operatorów &lt;em style="box-sizing: border-box; outline: none !important;"&gt;&amp;lt;&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;&amp;gt;&lt;/em&gt; tak jak w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Outer Join&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby napisać zapytanie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; równorzędne z zapytaniem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt; używającym &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LEFT OUTER JOIN&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;RIGHT OUTER JOIN&lt;/em&gt; należy użyć słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group join&lt;/strong&gt; i metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefaultIfEmpty&lt;/strong&gt;. Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group join&lt;/strong&gt; pozwala połączyć dwie sekwencje i wstawić je do trzeciej sekwencji.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dodajmy obiekt &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; do listy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;employees&lt;/em&gt; tak aby wartość pola &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateId&lt;/em&gt; nie istniała w liście &lt;em style="box-sizing: border-box; outline: none !important;"&gt;states&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;new Employee()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Sue"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    StateId&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod demonstruje pobranie wszystkich elementów z listy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;employees&lt;/em&gt; nawet jeżeli nie ma dopasowania na liście &lt;em style="box-sizing: border-box; outline: none !important;"&gt;states&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeByState = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; e &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employees&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;join&lt;/span&gt; s &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; states &lt;br /&gt;                          on e.StateId equals s.StateId &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;into&lt;/span&gt; employeeGroup&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; item &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt;&lt;br /&gt;                          employeeGroup.DefaultIfEmpty(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Empty })&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { e.LastName, item.StateName };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeByState)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.StateName);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kombinacja list jest wstawiana do obiektu nazwanego &lt;em style="box-sizing: border-box; outline: none !important;"&gt;employeeGroup&lt;/em&gt; poprzez użycie słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;into&lt;/strong&gt;. Druga klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;from&lt;/strong&gt; tworząca nową instancję obiektu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;State&lt;/em&gt; z wartościami &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateId&lt;/em&gt; równą 0 i pustym ciągiem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateName&lt;/em&gt; kiedy nie istnieje dopasowanie po polu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateId&lt;/em&gt;. Kiedy używamy klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;into&lt;/strong&gt; to nie możemy więcej odnieść się do zmiennej po prawej stronie klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;on&lt;/strong&gt;. Zamiast tego używamy zmiennej która wylicza wartości do nowej sekwencji, w przykładzie jest to zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;item&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pisząc wyrażenia zapytań możemy wykonywać tylko złączenia lewostronne &lt;em style="box-sizing: border-box; outline: none !important;"&gt;left join&lt;/em&gt; dla których kolejność zapisu jest istotna.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Klucze złożone&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Czasami zachodzi sytuacja w której musimy dokonać złączenia sekwencji za pomocą więcej niż jednej właściwości. Aby tego dokonać tworzymy typ anonimowy zawierający właściwości które chcemy porównać w klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowo zmieńmy klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Hometown&lt;/em&gt; tak aby posiadała właściwość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CityCode&lt;/em&gt; oraz zmieńmy klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; tak aby posiadała właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;City&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;State&lt;/em&gt; a nie posiadała &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateId&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Hometown&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; City { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; State { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; CityCode { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Employee&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; City { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; State { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu złącza dwie sekwencje używając właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;City&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;State&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;        {&lt;br /&gt;            FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;            LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;            City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;            State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;        }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;        {&lt;br /&gt;            FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;            LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;            City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;            State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;&lt;br /&gt;        }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;        {&lt;br /&gt;            FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;            LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;            City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, &lt;br /&gt;            State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Hometown&amp;gt; hometowns = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Hometown&amp;gt;()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Hometown()&lt;br /&gt;        {&lt;br /&gt;            City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;            State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;            CityCode = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"1234"&lt;/span&gt;&lt;br /&gt;        }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Hometown()&lt;br /&gt;        {&lt;br /&gt;            City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;            State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;, &lt;br /&gt;            CityCode = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"5678"&lt;/span&gt;&lt;br /&gt;        }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Hometown()&lt;br /&gt;        {&lt;br /&gt;            City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, &lt;br /&gt;            State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;            CityCode = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"9012"&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;var&lt;/span&gt; employeeByState = from e &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employees&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;join&lt;/span&gt; h &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; hometowns &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;on&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; { City = e&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;City, State = e&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;State } &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;equals&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; { City = h&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;City, State = h&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;State }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; { e&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;LastName, h&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;CityCode };&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeByState)&lt;br /&gt;{&lt;br /&gt;    Debug&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;WriteLine(employee&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;CityCode);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt; utworzone zostały dwa typy anonimowe z tymi samymi właściwościami. Równoważność jest określana poprzez porównanie wszystkich właściwości typów anonimowych.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Grupowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Bardzo często potrzeba nam pogrupować obiekty w celu zliczenia sum dla poszczególnych właściwości. Przykładowo możemy wykonać raport wyświetlający liczbę pracowników w każdym stanie. Aby tego dokonać można użyć klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group&lt;/strong&gt; w wyrażeniu zapytania. &lt;br /&gt;Poniższy fragment kodu tworzy listę pracowników i grupuje ich wg stanu. Liczba pracowników dla każdego stanu jest wyświetlana w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Output&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Group&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;Employee&amp;gt;()&lt;br /&gt;                                   {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;                                           {&lt;br /&gt;                                               FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                                               LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                                               City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;                                               State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;                                           }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;                                           {&lt;br /&gt;                                               FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                                               LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                                               City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;                                               State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;&lt;br /&gt;                                           }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;                                           {&lt;br /&gt;                                               FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;                                               LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;                                               City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, &lt;br /&gt;                                               State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;                                           }&lt;br /&gt;                                   };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeesByState = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; e &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employees &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;group&lt;/span&gt; e by e.State;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeGroup &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeesByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employeeGroup.Key + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": "&lt;/span&gt; + employeeGroup.Count());&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeGroup)&lt;br /&gt;        {&lt;br /&gt;            Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.State);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W powyższym przykładzie nie ma klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt;. Jest to możliwe dlatego, że klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group&lt;/strong&gt; zwraca kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IGrouping&amp;lt;TKey,TElement&amp;gt;&lt;/strong&gt;. Jest to kolekcja zawierająca właściwość dla klucza po którym sekwencja została pogrupowana. &lt;br /&gt;W powyższym przykładzie są dwie pętle &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;foreach&lt;/strong&gt;. Pierwsza iteruje po kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IGrouping&lt;/strong&gt; i wyświetla właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Key&lt;/strong&gt; oraz &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Count&lt;/strong&gt; jako liczbę elementów w grupie. Wewnętrzna pętla iteruje po elementach każdej grupy i wyświetla nazwisko i stan dla każdego pracownika w grupie.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group by&lt;/strong&gt; można dodać logikę grupującą po dowolnych właściwościach. &lt;br /&gt;Poniższy przykład grupuje liczby parzyste i nieparzyste oraz wyświetla ich liczbę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GroupV2&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;    var groupedNumbers = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from i in myArray&lt;br /&gt;        group i &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;by&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt; ? &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Even"&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Odd"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    foreach (var groupNumber in groupedNumbers)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(groupNumber.Key + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": "&lt;/span&gt; + groupNumber.Sum());&lt;br /&gt;        foreach(var number in groupNumber)&lt;br /&gt;        {&lt;br /&gt;            Debug.WriteLine(number);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Grupując sekwencje można również użyć klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt;, ale trzeba również użyć słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;into&lt;/strong&gt; w klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu demonstruje wyświetlenie liczb parzystych i nieparzystych oraz ich liczby:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GroupV3&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;[] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;    var groupedNumbers = from i in myArray&lt;br /&gt;                         group i by i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt; ? &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Even"&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Odd"&lt;/span&gt;&lt;br /&gt;                         into g select &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { Key = g.Key, SumOfNumbers = g.Sum() };&lt;br /&gt;&lt;br /&gt;    foreach (var groupNumber in groupedNumbers)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(groupNumber.Key + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": "&lt;/span&gt; + groupNumber.SumOfNumbers);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Zapytania oparte o metody&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie instrukcje które można wyrazić za pomocą wyrażeń zapytań &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; można również napisać za pomocą zapytań &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; opartych o metody. Funkcjonalnie są one równoważne lecz posiadają inną składnię.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zapytania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; oparte o metody są metodami rozszerzającymi znajdującymi się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Linq&lt;/strong&gt;. Metody te rozszerzają wszystkie typy implementujące interfejsy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IQueryable&lt;/strong&gt;. Metody zapytań jako parametr przyjmują wyrażenia lambda, które reprezentują logikę która ma zostać wykonana w czasie enumeracji sekwencji. &lt;br /&gt;Przypomnijmy prosty przykład wyrażenia zapytania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; które zwraca parzyste liczby z tablicy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var evenNumbers = from i in myArray&lt;br /&gt;    where i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;    select i;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Równoważne zapytanie oparte o metody rozszerzające &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; wygląda następująco:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var evenNumbers = myArray.Where(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;i&lt;/em&gt; reprezentuje element w tablicy a kod po prawej stronie operatora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;=&amp;gt;&lt;/strong&gt; reprezentuje logike wykonywaną w czasie enumeracji tablicy.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Filtrowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Filtrowanie danych odbywa się z użyciem metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Where&lt;/strong&gt; do której przekazujemy wyrażenie lambda jako parametr które zwraca wartość typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;bool&lt;/em&gt; a metoda zwraca tylko te elementy sekwencji które spełniają warunek, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;myArray.Where&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;(i =&amp;gt; i % 2 == 0)&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W metodzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Where&lt;/strong&gt; można używać operatorów (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&amp;amp;&lt;/strong&gt;) lub (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;||&lt;/strong&gt;), np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;var evenNumbers = myArray.Where(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt; &amp;amp;&amp;amp; i &amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli wymagamy operatora pierwszeństwa operacji to zamiast niego możemy użyć wielu metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Where&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;var evenNumbers = myArray.Where(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).Where(i =&amp;gt; i &amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Sortowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Sekwencje można sortować używając metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OrderBy&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OrderByDescending&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; evenNumbers = myArray.Where(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).OrderByDescending(i =&amp;gt; i);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli musimy sortować po więcej niż jednej właściwości służą do tego metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThenBy&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThenByDescending&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; MethodBasedOrderByStateThenCity()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Hometown&amp;gt; hometowns = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Hometown&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Philadelphia"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown() { City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Trenton"&lt;/span&gt;, State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; orderedHometowns = hometowns.OrderBy(h =&amp;gt; h.State).ThenBy(h =&amp;gt; h.City);&lt;br /&gt;&lt;br /&gt;    foreach (Hometown hometown &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; orderedHometowns)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(hometown.City + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + hometown.State);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Projekcja&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można dokonywać projekcji obiektów za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Select&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private static void MethodBasedProjectionV1()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    List&amp;lt;Person&amp;gt; people&lt;/span&gt; = new List&amp;lt;Person&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;        new Person()&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Address1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"First St"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                City&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                State&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Zip&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19084"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;        new Person()&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Address1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Second St"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                City&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                State&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Zip&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"08560"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;        new Person()&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Address1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Third St"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                City&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ft Washington"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                State&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Zip&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19034"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    var lastNames = people.Select(p =&amp;gt; p.LastName);&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; lastName in lastNames)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;        Debug.WriteLine(lastName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W metodzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Select&lt;/strong&gt; można tworzyć typy anonimowe tak samo jak w wyrażeniach zapytań. Jedyną różnicą jest konieczność użycia wyrażenia lambda. &lt;br /&gt;Poniższy fragment kodu tworzy typ anonimowy z właściwościami &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private static void MethodBasedProjectionV2()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    List&amp;lt;Person&amp;gt; people&lt;/span&gt; = new List&amp;lt;Person&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;        new Person()&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Address1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"First St"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                City&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                State&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Zip&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19084"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;        new Person()&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Address1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Second St"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                City&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                State&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Zip&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"08560"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;        new Person()&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                FirstName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                LastName&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Address1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Third St"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                City&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ft Washington"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                State&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;                Zip&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19034"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    var names = people.Select(p =&amp;gt; new { p.FirstName, p.LastName });&lt;br /&gt;&lt;br /&gt;    foreach (var name in names)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;        Debug.WriteLine(name.FirstName + ", " + name.LastName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Nazwy właściwości typów anonimowych można jawnie określać, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; names = people.Select(p =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { First = p.FirstName, Last = p.LastName });&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieje również metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SelectMany&lt;/strong&gt; którą można wykorzystać do spłaszczenia dwóch sekwencji do jednej sekwencji podobnie do działania &lt;em style="box-sizing: border-box; outline: none !important;"&gt;join&lt;/em&gt;. &lt;br /&gt;Poniższy przykład spłaszcza listy pracowników i stanów i zwraca kombinację tych list:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; MethodBasedProjectionV4()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;State&amp;gt; states = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;State&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeByState =&lt;br /&gt;        employees.SelectMany(&lt;br /&gt;            e =&amp;gt; states.Where(s =&amp;gt; e.StateId == s.StateId)&lt;br /&gt;                       .Select(s =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { e.LastName, s.StateName }));&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.StateName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Złączenia&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Join&lt;/strong&gt; pozwala na złączenie dwóch sekwencji używając wspólnej właściwości lub zestawu właściwości. &lt;br /&gt;Poniższy fragment kodu łączy listę pracowników z listą stanów używając właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;StateId&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; MethodBasedJoin()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;State&amp;gt; states = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;State&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeByState = employees.Join(&lt;br /&gt;        states, &lt;br /&gt;        e =&amp;gt; e.StateId, &lt;br /&gt;        s =&amp;gt; s.StateId, &lt;br /&gt;        (e, s) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { e.LastName, s.StateName });&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.StateName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista &lt;em style="box-sizing: border-box; outline: none !important;"&gt;employees&lt;/em&gt; jest rozważana jako sekwencja zewnętrzna. Pierwszym parametrem metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Join&lt;/strong&gt; jest sekwencją którą chcemy złączyć, w przykładzie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;states&lt;/em&gt;, która jest rozważana jako sekwencja wewnętrzna. Drugim parametrem jest klucz złączenia sekwencji zewnętrznej. Trzecim parametrem jest klucz złączenia sekwencji wewnętrznej. Domyślnie użyte zostanie porównanie równoważności sekwencji. Czwartym parametrem jest wyrażenie lambda tworzące wynik złączenia.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Outer Join&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Złączenia typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Outer Join&lt;/em&gt; są realizowane za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GroupJoin&lt;/strong&gt;. &lt;br /&gt;Poniższy przykład realizuje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;left join&lt;/em&gt; list pracowników i stanów. Jeżeli nie ma połączenia w liście stanów to nazwa stanu będzie pusta:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; void MethodBasedOuterJoin()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Sue"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;List&lt;/span&gt;&amp;lt;State&amp;gt; states = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;List&lt;/span&gt;&amp;lt;State&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeByState =&lt;br /&gt;        employees.GroupJoin(&lt;br /&gt;            states, &lt;br /&gt;            e =&amp;gt; e.StateId, &lt;br /&gt;            s =&amp;gt; s.StateId, &lt;br /&gt;            (e, employeeGroup) =&amp;gt; employeeGroup.Select(&lt;br /&gt;                s =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { LastName = e.LastName, StateName = s.StateName })&lt;br /&gt;                .DefaultIfEmpty(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { LastName = e.LastName, StateName = string.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Empty&lt;/span&gt; }))&lt;br /&gt;                .SelectMany(e =&amp;gt; e);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee in employeeByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.StateName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pierwsze trzy parametry metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GroupJoin&lt;/strong&gt; są analogiczne do metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Join&lt;/strong&gt;. &lt;br /&gt;Czwarty parametr jest wyrażeniem lambda dla sekwencji zewnętrznej i nowej listy utworzonej analogicznie do słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;into&lt;/strong&gt; używanego w wyrażeniach zapytań, którą dowolnie nazywamy, w przykładzie to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;employeeGroup&lt;/em&gt;. &lt;br /&gt;Używamy metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Select&lt;/strong&gt; do wyliczenia wszystkich wartości w sekwencji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;employeeGroup&lt;/em&gt; i metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefaultIfEmpty&lt;/strong&gt; kiedy nie ma dopasowania pomiędzy sekwencjami. Na konie należy wywołać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SelectMany&lt;/strong&gt; aby zwrócić sekwencję obiektów.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Klucze złożone&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klucze złożone tworzymy poprzez typy anonimowe. &lt;br /&gt;Poniższy fragment kodu demonstruje połączenie sekwencji po dwóch właściwościach:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; MethodBasedCompositeKey()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Hometown&amp;gt; hometowns = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Hometown&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown()&lt;br /&gt;            {&lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;                CityCode = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"1234"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown()&lt;br /&gt;            {&lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;, &lt;br /&gt;                CityCode = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"5678"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hometown()&lt;br /&gt;            {&lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;, &lt;br /&gt;                CityCode = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"9012"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeByState = employees.Join(&lt;br /&gt;        hometowns, &lt;br /&gt;        e =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { City = e.City, State = e.State }, &lt;br /&gt;        h =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { City = h.City, State = h.State }, &lt;br /&gt;        (e, h) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { e.LastName, h.CityCode });&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.CityCode);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Grupowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GroupBy&lt;/strong&gt; może zostać użyta do grupowania po jednym lub więcej polu. Jest ona równoważna do uzycia słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group&lt;/strong&gt; w wyrażeniach zapytań. &lt;br /&gt;Poniższy fragment kodu grupuje listę pracowników wg stanu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MethodBasedGroupV1&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Havertown"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ewing"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;                City = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fort Washington"&lt;/span&gt;, &lt;br /&gt;                State = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeesByState = employees.GroupBy(e =&amp;gt; e.State);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeeGroup &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeesByState)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employeeGroup.Key + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": "&lt;/span&gt; + employeeGroup.Count());&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeGroup)&lt;br /&gt;        {&lt;br /&gt;            Debug.WriteLine(employee.LastName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;", "&lt;/span&gt; + employee.State);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GroupBy&lt;/strong&gt; zwraca kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IGrouping&amp;lt;TKey, TElement&amp;gt;&lt;/strong&gt;, która może zostać wyliczana aby wykonać funkcje agregujące na elementach grupy. &lt;br /&gt;Jeżeli chcemy grupować po więcej niż jednym polu należy użyć typu anonimowego jako parametru metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GroupBy&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu grupuje pracowników wg miasta i stanu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employeesByState = employees.GroupBy(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;e&lt;/span&gt; =&amp;gt; new { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;e&lt;/span&gt;.City, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;e&lt;/span&gt;.State });&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Funkcje agregujące&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Funkcje agregujące pozwalają na wykonanie operacji obliczeniowych takich jak &lt;em style="box-sizing: border-box; outline: none !important;"&gt;average&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sum&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;count&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;max&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;min&lt;/em&gt; na kolekcjach. Przykładowo mając listę reprezentującą faktury możemy szybko wykonać sumę faktury używając metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Sum&lt;/strong&gt;. Te funkcje są dostępne jedynie jako metody ale można ich używać również w wyrażeniach zapytań. &lt;br /&gt;Poniższy fragment kodu demonstruje wyrażenie zapytania oraz jego równoważne zapytanie bazujące na metodach dla przykładowych funkcji agregujących:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;count&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;count&lt;/span&gt; = (from i &lt;span style="box-sizing: border-box; outline: none !important;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Count&lt;/span&gt;();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;count&lt;/span&gt; = myArray.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Where&lt;/span&gt;(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Count&lt;/span&gt;();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można również odroczyć wykonanie zapytania używając następującej składni:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; evenNumbers = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; i &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; count = evenNumbers.Count();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;average&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; average = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; i &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).Average();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;double average = myArray.Where&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;(i =&amp;gt; i % 2 == 0)&lt;/span&gt;.Average&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;()&lt;/span&gt;;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;sum&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;sum&lt;/span&gt; = (from i &lt;span style="box-sizing: border-box; outline: none !important;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Sum&lt;/span&gt;();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;sum&lt;/span&gt; = myArray.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Where&lt;/span&gt;(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Sum&lt;/span&gt;();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;min&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;sum&lt;/span&gt; = (from i &lt;span style="box-sizing: border-box; outline: none !important;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Min&lt;/span&gt;();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;sum&lt;/span&gt; = myArray.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Where&lt;/span&gt;(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Min&lt;/span&gt;();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;max&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;sum&lt;/span&gt; = (from i &lt;span style="box-sizing: border-box; outline: none !important;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Max&lt;/span&gt;();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;sum&lt;/span&gt; = myArray.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Where&lt;/span&gt;(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Max&lt;/span&gt;();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Pierwszy i ostatni element&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieją dwie dodatkowe funkcje które umożliwiają odnalezienie pierwszego i ostatniego elementu w sekwencji. Dostępne są jako metody ale można ich również użyć w wyrażeniach zapytań. Funkcje te mogą być użyteczne kiedy chcemy znaleźć w sekwencji pierwszy lub ostatni element który spełnia określony warunek, np pierwszy numer parzysty w sekwencji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;first&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; first = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; i &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).First();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; first = myArray.Where(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).First();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;last&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; first = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; i &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myArray&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;where&lt;/span&gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; i).Last();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; first = myArray.Where(i =&amp;gt; i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;).Last();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Konkatenacja&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Concat&lt;/strong&gt; pozwala na złączenie dwóch sekwencji w jedną na zasadzie podobnej do operatora &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UNION&lt;/em&gt; w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt;. &lt;br /&gt;Poniższy fragment kodu złącza dwie listy pracowników w jedną:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; Concat()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees2 = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bill"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Peters"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Donalds"&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Chris"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jacobs"&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; combinedEmployees = employees.Concat(employees2);&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; combinedEmployees)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.LastName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Należy uważać ponieważ typy obu złączanych ze sobą list nie muszą byś takie same. Można kombinować różne typy poprzez wybieranie typu anonimowego z każdej sekwencji. &lt;br /&gt;Poniższy kod tworzy kombinację listy pracowników i listy osób tworząc typ anonimowy który zawiera tylko nazwiska:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;private &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; ConcatV2()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Person&amp;gt; people = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Person&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bill"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Peters"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Donalds"&lt;/span&gt; }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Chris"&lt;/span&gt;, LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jacobs"&lt;/span&gt; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; combinedEmployees =&lt;br /&gt;        employees.Select(e =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { Name = e.LastName })&lt;br /&gt;            .Concat(people.Select(p =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; { Name = p.LastName }));&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; employee &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; combinedEmployees)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(employee.Name);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Dzielenie sekwencji&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Sekwencje można dzielić lub stronicować poprzez użycie metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Skip&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Take&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Skip&lt;/strong&gt; pobiera jako parametr liczbę całkowitą która określa ilość elementów które ma pominąć w sekwencji. &lt;br /&gt;Poniższy fragment kody demonstruje pominięcie pierwszego elementu z listy pracowników:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; newEmployees&lt;/span&gt; = employees.Skip(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Take&lt;/strong&gt; pobiera jako parametr liczbę całkowitą która określa ilość elementów które ma pobrać z sekwencji. &lt;br /&gt;Poniższy fragment kody demonstruje pobranie dwóch elementów z listy pracowników:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; newEmployees&lt;/span&gt; = employees.Take(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Obie metody mogą być użyteczne przy stronicowaniu wyników zapytania. &lt;br /&gt;Poniższy fragment kodu demonstruje pobranie trzeciej strony wyników wyświetlanych po 10:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;var&lt;/span&gt; newEmployees = employees&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Skip&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;20&lt;/span&gt;)&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Take&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Usuwanie duplikatów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Distinct&lt;/strong&gt; zwraca listę niepowtarzających się wartości z sekwencji. &lt;br /&gt;Poniższy fragment kodu zwraca niepowtarzające się liczby z tablicy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] myArray = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;var distinctArray = myArray.Distinct();&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i in distinctArray)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby używać metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Distinct&lt;/strong&gt; na własnych typach należy implementować w nich interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; ponieważ metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Distinct&lt;/strong&gt; używa domyślnego porównywania równości obiektów. Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Equals&lt;/strong&gt; do zaimplementowania która porównuje obiekty. Należy również nadpisać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetHashCode&lt;/strong&gt; obiektu tak aby zwracała kod skrótu na podstawie właściwości w swoim obiekcie.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy przykład demonstruje porównanie obiektów niestandardowych:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; State : IEquatable&amp;lt;State&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; StateId { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; StateName { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Equals&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(State other)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Object.ReferenceEquals(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;, other))&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (StateId == other.StateId &amp;amp;&amp;amp; StateName == StateName)&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;false&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt; override &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetHashCode&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; StateId.GetHashCode() ^ StateName.GetHashCode();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DistinctCodeLab&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;State&amp;gt; states = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;State&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State(){ StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt;},&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NJ"&lt;/span&gt;},&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; },&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; State() { StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, StateName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NY"&lt;/span&gt;}&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    var distintStates = states.Distinct();&lt;br /&gt;&lt;br /&gt;    foreach (State state in distintStates)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(state.StateName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Wykorzystanie LINQ to XML&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ to XML&lt;/strong&gt; pozwala na łatwą konwersję sekwencji do dokumentu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;. &lt;br /&gt;Poniższy fragment kodu konwertuje listę pracowników do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; static &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;void&lt;/span&gt; LINQToXML()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt; employees = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;Employee&amp;gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;&lt;br /&gt;            }, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; Employee()&lt;br /&gt;            {&lt;br /&gt;                FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;, &lt;br /&gt;                LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;, &lt;br /&gt;                StateId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;            }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;var&lt;/span&gt; xmlEmployees = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; XElement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Root"&lt;/span&gt;, &lt;br /&gt;        from e &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employees&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; XElement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Employee"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; XElement(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;, e&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;FirstName), &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; XElement(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;, e&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;LastName)));&lt;br /&gt;&lt;br /&gt;    Debug&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;WriteLine(xmlEmployees);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Root&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;John&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;Smith&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;Jane&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;Doe&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;Jack&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;Jones&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Root&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XElement&lt;/strong&gt; znajduje się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Xml.Linq&lt;/strong&gt;. Pierwszym parametrem konstruktora jest nazwa elementu. Drugim parametrem jest tablica parametrów &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ParamArray&lt;/em&gt;, co oznacza, że można przekazać zmienną liczbę argumentów do konstruktora.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Language Integrated Query LINQ&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obiekty implementujące interfejsy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IQueryable&lt;/strong&gt; mogą myć odpytywane za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyniki zapytań &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; są zwykle zwracane do zmiennej typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;var&lt;/strong&gt;, która jest zmienną typowaną niejawnie.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wyrażenia zapytań&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyrażenia zapytań zawierają klauzulę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;from&lt;/strong&gt; i mogą zawierać klauzule &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group by&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;order by&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Złączenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt; używają zawsze równoważności i dlatego używa się słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;equals&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonanie zapytania następuje w momencie jego wyliczenia. Można wymusić wykonanie zapytania używając funkcji agregującej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wiele operacji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;where&lt;/strong&gt; jest równoważne z operatorem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;and&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;orderby&lt;/strong&gt; jest używana do sortowania wyników, można oddzielić właściwości przecinkiem jeżeli chcemy sortować po więcej niż jednej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt; można utworzyć nowy typ dla wyników. Taka operacja nazywana jest projekcją.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby utworzyć złączenie zewnętrzne (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;left join&lt;/em&gt;) należy użyć klauzuli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;into&lt;/strong&gt; i wywołać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefaultIfEmpty&lt;/strong&gt; aby ustawić wartości obiektu kiedy nie ma dopasowania w złączeniu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;join&lt;/strong&gt; może używać typów anonimowych aby połączyć sekwencje po więcej niż jednym polu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;group by&lt;/strong&gt; zwraca kolekcję typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IGrouping&amp;lt;TKey, TElement&amp;gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Zapytania LINQ oparte o metody&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapytania &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LINQ&lt;/em&gt; oparte o metody są równoważne z wyrażeniami zapytań.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapytania &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LINQ&lt;/em&gt; oparte o metody używają wyrażeń lambda.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SelectMany&lt;/strong&gt; służy do spłaszczenia dwóch sekwencji w jedną.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby uzyskać złączenie zewnętrzne należy użyć metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GroupJoin&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefaultIfEmpty&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dwie sekwencje można złączy za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Concat&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Skip&lt;/strong&gt; pomija określoną liczbę wierszy wyniku zapytania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Take&lt;/strong&gt; pobiera określoną liczbę wierszy wyniku zapytania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Distinct&lt;/strong&gt; pobiera niepowtarzające się elementy sekwencji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;LINQ to XML&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XElement&lt;/strong&gt; pozwala na zwrócenie wyniku zapytania &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LINQ&lt;/em&gt; jako dokument &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Mon, 29 Feb 2016 23:17:03 Z</pubDate>
      <a10:updated>2016-02-29T23:17:03Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1126</guid>
      <link>http://smsoft.pl/blog/viii-praca-z-danymi/</link>
      <title>VIII. Praca z danymi</title>
      <description>&lt;p&gt;&lt;span style="font-size: 32px;"&gt;&lt;span style="color: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Operacje I/O&lt;/strong&gt; - zapis i odczyt z plików oraz strumienie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Konsumpcja danych&lt;/strong&gt; - pobieranie, dodawanie, aktualizacja i usuwanie danych z bazy danych. Użycie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Entity Framework&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Services&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serializacja&lt;/strong&gt; - serializacja i deserializacja danych używając serializacji binarnej, XML, JSON, Data Contract i niestandardowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Kolekcje danych&lt;/strong&gt; - przechowywanie i odczyt danych w kolekcjach i tablicach.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Praca z kolekcjami&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zrozumienie jak manipulować zbiorami danych jest kluczową umiejętnością dla każdego programisty. &lt;br /&gt;Tablice są najbardziej prymitywnymi typami w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; służącymi do przechowywania zbiorów danych, posiadają one oraniczoną funkcjonalność. Kolekcje są natomiast terminem ogólnym który obejmuje listy, słowniki, kolejki i inne obiekty.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Tablice&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tablica jest najbardziej podstawowym typem używanym do przechowywania zbiorów danych. Tablice posiadają elementy do których odnosimy się za pomocą indeksu używając nawiasów kwadratowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[]&lt;/strong&gt;. &lt;br /&gt;Poniższy kod tworzy jednowymiarową tablicę liczb całkowitych:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] mySet = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tworząc tablicę trzeba określić liczbę elementów które tablica może posiadać. W przykładzie liczba elementów to 5. &lt;br /&gt;Tablice mogą być również wielowymiarowe. Przykład tworzenia tablicy dwuwymiarowej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[,] mySet = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;;&lt;br /&gt;mySet[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tablice mogą posiadać do 2,147,483,647 wymiarów.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie tablice dziedziczą z klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Array&lt;/strong&gt;. Klasa ta posiada właściwości i metody użyteczne przy pracy z tablicami. Dwie najbardziej przydatne właściwości tablic to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Length&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rank&lt;/strong&gt;. Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Length&lt;/strong&gt; wskazuje całkowitą liczbę elementów we wszystkich wymiarach tablicy. Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rank&lt;/strong&gt; wskazuje liczbę wymiarów tablicy.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clone&lt;/strong&gt; jest używana do wykonywania płytkiej kopii (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;shallow copy&lt;/em&gt;) tablicy. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CopyTo&lt;/strong&gt; natomiast kopiuje elementy tablicy do innej tablicy.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Płytka kopia klonuje referencje do oryginalnych elementów tablicy więc dla typów referencyjnych są to te same elementy, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[]&lt;/span&gt; orginal = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[1]&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;orginal&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt; = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;() { Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[]&lt;/span&gt; clone = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[]&lt;/span&gt;)orginal.Clone();&lt;br /&gt;&lt;br /&gt;clone&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt;.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Mary"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Original name "&lt;/span&gt; + orginal&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt;.Name);&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Clone name "&lt;/span&gt; + clone&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt;.Name);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Original name Mary &lt;br /&gt;Clone name Mary&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby zmienić element tylko w sklonowanej tablicy należy zastąpić go innym a nie zmieniać jego wartość, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[]&lt;/span&gt; orginal = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[1]&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;orginal&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt; = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;() { Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[]&lt;/span&gt; clone = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[]&lt;/span&gt;)orginal.Clone();&lt;br /&gt;&lt;br /&gt;clone&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt; = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;() { Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Original name "&lt;/span&gt; + orginal&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt;.Name);&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Clone name "&lt;/span&gt; + clone&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;[0]&lt;/span&gt;.Name);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Original name John &lt;br /&gt;Clone name Bob&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Kolekcje&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcje to ogólny termin dla specjalnych klas które są bardziej elastyczne niż tablice. Te klasy pozwalają na dynamiczne dodawanie i usuwanie elementów po ich zainicjowaniu, łączenie elementów kluczami, automatyczne sortowanie elementów i dodawanie elementów różnych typów. &lt;br /&gt;Najczęściej wykorzystywane kolekcje to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;List&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;List&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt;. &lt;br /&gt;Klasy kolekcji znajdują się w przestrzeniach nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Generic&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Concurrent&lt;/strong&gt;. Klasy zawarte w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Concurrent&lt;/strong&gt; służą do wykonywania operacji wielowątkowych i nie będą opisane w tej notatce.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;System.Collections&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections&lt;/strong&gt; zawiera klasy używane kiedy w kolekcji mamy dane różnego typu. Te kolekcje mogą być miksem typów wartości, klas lub struktur. &lt;br /&gt;Lista klas przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; - tworzy kolekcję której wielkość jest dynamiczna i może posiadac elementy różnego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HashTable&lt;/strong&gt; - tworzy kolekcję par klucz/wartość której wielkość jest dynamiczna i może posiadac elementy różnego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt; - tworzy kolekcję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;first-in-first-out&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&lt;/strong&gt; - tworzy kolekcję par klucz/wartość której elementy są posortowane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; - tworzy kolekcję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;last-in-first-out&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;ArrayList&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; pozwala na dynamiczne dodawanie elementów do kolekcji. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; jest użyteczna kiedy nie znamy liczby elementów w momencie inicjalizacji kolekcji oraz kiedy chcemy przechowywać w kolekcji dane różnego typu. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; pobiera jako parametr typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Object&lt;/strong&gt; i pozwala w ten sposób na przechowywanie dowolnego typu. &lt;br /&gt;Poniższy kod tworzy obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; i dodaje do niego elementy trzech różnych typów:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ArrayList myList = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"hello world"&lt;/span&gt;);&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; DateTime(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2012&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;01&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;01&lt;/span&gt;));&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej wykorzystywanych właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Capacity&lt;/strong&gt; - pobiera lub ustawia liczbę elementów w kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Count&lt;/strong&gt; - pobiera aktualna liczbę elementów w kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Item&lt;/strong&gt; - pobiera lub ustawia element określony indeksem.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej wykorzystywanych metod klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; - dodaje element na końcu kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddRange&lt;/strong&gt; - dodaje wiele elementów na końcu kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinarySearch&lt;/strong&gt; - przeszukuje kolekcję używając domyślnej klasy porównywania i zwraca indeks elementu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; - usuwa wszystkie elementy kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Contains&lt;/strong&gt; - sprawdza czy element należy do kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CopyTo&lt;/strong&gt; - kopiuje kolekcję do kompatybilnej tablicy jednowymiarowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IndexOf&lt;/strong&gt; - przeszukuje kolekcje i zwraca indeks pierwszego wystąpienia elementu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Insert&lt;/strong&gt; - dodaje element na wyznaczonym indeksem miejscu w kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Remove&lt;/strong&gt; - usuwa element z kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RemoveAt&lt;/strong&gt; - usuwa element wyznaczony indeksem z kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reverse&lt;/strong&gt; - odwraca kolejność elementów w kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Sort&lt;/strong&gt; - sortuje elementy w kolekcji.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład sortowania dla elementów typu wartości:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ArrayList myList = new ArrayList()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;myList.Add(4)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;myList.Add(1)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;myList.Add(5)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;myList.Add(3)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;myList.Add(2)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;myList.Sort()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;foreach (int i in myList)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(i.ToString())&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;1 &lt;br /&gt;2 &lt;br /&gt;3 &lt;br /&gt;4 &lt;br /&gt;5&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Co jeżeli chcemy przechowywać obiekty które nie są standardowymi typami w kolekcji? Przykładowo jeżeli utworzymy klasę z właściwością &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ID&lt;/em&gt; która przechowuje identyfikator obiektu, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MyObject&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; ID{ &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Teraz utworzymy kolekcję z pięcioma instancjami naszej klasy i wywołamy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Sort&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ArrayList myList = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;&lt;br /&gt;myList.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;{ ID = 4 }&lt;/span&gt;);&lt;br /&gt;myList.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;{ ID = 1 }&lt;/span&gt;);&lt;br /&gt;myList.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;{ ID = 5 }&lt;/span&gt;);&lt;br /&gt;myList.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;{ ID = 3 }&lt;/span&gt;);&lt;br /&gt;myList.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;{ ID = 2 }&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;myList.Sort();&lt;br /&gt;&lt;br /&gt;foreach (MyObject i &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myList)&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;{&lt;br /&gt;    Console.WriteLine(i.ID.ToString());&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli uruchomimy ten kod to w rezultacie otrzymamy wyjątek wyrzucony w metodzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Sort&lt;/strong&gt;: &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Failed to Compare Two Elements in the Array.&lt;/em&gt; Dzieje się tak ponieważ metoda nie wie jak wykonac sortowanie dla naszej klasy. Aby to naprawić należy zaimplementować interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; w utworzonej klasie i zaimplementować metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CompareTo&lt;/strong&gt; służącą do porównywania wartości elementów. Metoda ta pobiera jeden argument - obiekt który chcemy porównać i w wyniku zwraca liczbę mniejszą od zera jeżeli aktualna instancja jest wyższa w kolejności sortowania, zero jeżeli aktualna instancja jest równa lub liczbę większą od zera jeżeli aktualna instancja jest mniejsza w kolejności sortowania.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MyObject&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IComparable&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; ID{ &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;CompareTo&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; obj&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        MyObject obj1 = obj &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;as&lt;/span&gt; MyObject;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.ID.CompareTo(obj1.ID);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Innym powszechnym zastosowaniem tablic i kolekcji jest możliwość przeszukiwania tablicy. Można do tego celu uzyć pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;for&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;foreach&lt;/strong&gt; albo użyć dużo szybszej metody jaką jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinarySearch&lt;/strong&gt;. Aby użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinarySearch&lt;/strong&gt; elementy kolekcji musza być posortowane. Metoda&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinarySearch&lt;/strong&gt; zwraca indeks elementu który odnalazła. Jeżeli nic nie znalazła to wynikiem będzie liczba ujemna, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ArrayList myList = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt; });&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt; });&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt; });&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt; });&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;myList.Sort();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; foundIndex = myList.BinarySearch(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyObject() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (foundIndex &amp;gt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(((MyObject)myList[foundIndex]).ID.ToString());&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Element not found"&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Hashtable&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Hashtable&lt;/strong&gt; pozwala na przechowywanie par klucz/wartość dowolnego typu. Dane są zapisywane zgodnie z hashcode klucza i mogą być dostępne za pomocą klucza a nie indeksu elementu. &lt;br /&gt;Poniższy kod tworzy kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Hashtable&lt;/strong&gt; i wstawia do niej elementy różnego typu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Hashtable myHashtable = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Hashtable();&lt;br /&gt;&lt;br /&gt;myHashtable.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"one"&lt;/span&gt;);&lt;br /&gt;myHashtable.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"two"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;);&lt;br /&gt;myHashtable.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"three"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;Debug.WriteLine(myHashtable[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;].ToString());&lt;br /&gt;Debug.WriteLine(myHashtable[&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"two"&lt;/span&gt;].ToString());&lt;br /&gt;Debug.WriteLine(myHashtable[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;].ToString());&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;one &lt;br /&gt;2 &lt;br /&gt;three&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Queue&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt; jest kolekcją typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;first-in-first-out&lt;/em&gt;. Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt; może być użyteczna, gdy trzeba przechowywać dane w określonej kolejności, do sekwencyjnego przetwarzania. &lt;br /&gt;Poniższy kod tworzy kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt; i dodaje do niej trzy elementy, usuwa wszystkie elementy i wyświetla ich wartość:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Queue myQueue = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Queue();&lt;br /&gt;&lt;br /&gt;myQueue.Enqueue(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"first"&lt;/span&gt;);&lt;br /&gt;myQueue.Enqueue(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"second"&lt;/span&gt;);&lt;br /&gt;myQueue.Enqueue(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"third"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;count&lt;/span&gt; = myQueue.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Count&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;count&lt;/span&gt;; i++)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(myQueue.Dequeue());&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;first &lt;br /&gt;second &lt;br /&gt;third&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zamiast metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt; posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Enqueue&lt;/strong&gt;, która dodaje element do kolejki. Do usuwania elementu używana jest metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dequeue&lt;/strong&gt;. Nie można dostać się do elementów kolejki ani za pomocą klucza ani indeksu. Zamiast tego można tylko dodać, usunąć lub podejrzeć wartość na sczycie kolejki. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Peek&lt;/strong&gt; zwraca wartość elementu na szczycie kolejki ale go nie usuwa.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;SortedList&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&lt;/strong&gt; zawiera pary klucz/wartość ale jest inna niż &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Hashtable&lt;/strong&gt; ponieważ do elementu możemy odnieść się za pomocą klucza i indeksu, oraz dlatego, że jest posortowana. Elementy kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&lt;/strong&gt; są sortowane używając implementacji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; dla klucza lub implementacji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt; kiedy lista jest tworzona. &lt;br /&gt;Poniższy kod tworzy kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&lt;/strong&gt; i dodaje do niej trzy elementy oraz wyświetla je:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SortedList mySortedList = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SortedList();&lt;br /&gt;&lt;br /&gt;mySortedList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"three"&lt;/span&gt;);&lt;br /&gt;mySortedList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"second"&lt;/span&gt;);&lt;br /&gt;mySortedList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"first"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;foreach (DictionaryEntry item in mySortedList)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(item.Value);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;first &lt;br /&gt;second &lt;br /&gt;third&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Do kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&lt;/strong&gt; można dodawać tylko elementy których klucze mogą być ze sobą porównywane.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Stack&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; jest kolekcją typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;last-in-first-out&lt;/em&gt;. Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; może być użyteczna, gdy trzeba przechowywać dane w określonej kolejności, do sekwencyjnego przetwarzania. Zamiast metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Push&lt;/strong&gt;. Do usuwania elementu używana jest metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Pop&lt;/strong&gt;. Metoda&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Peek&lt;/strong&gt; zwraca wartość elementu na szczycie kolejki ale go nie usuwa. &lt;br /&gt;Poniższy kod tworzy kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; i dodaje do niej trzy elementy, usuwa wszystkie elementy i wyświetla ich wartość:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Stack myStack = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Stack();&lt;br /&gt;&lt;br /&gt;myStack.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Push&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"first"&lt;/span&gt;);&lt;br /&gt;myStack.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Push&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"second"&lt;/span&gt;);&lt;br /&gt;myStack.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Push&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"third"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;count&lt;/span&gt; = myStack.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Count&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;count&lt;/span&gt;; i++)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(myStack.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Pop&lt;/span&gt;());&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;third &lt;br /&gt;second &lt;br /&gt;first&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;System.Collections.Generic&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Generic&lt;/strong&gt; zawiera klasy używane kiedy znamy typ danych które będziemy przechowywali w kolekcji i chcemy aby cała kolekcja zawierała elementy tylko jednego typu. &lt;br /&gt;Kolekcje w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Generic&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt; - kolekcja par klucz/wartość tego samego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;List&amp;lt; T &amp;gt;&lt;/strong&gt; - kolekcja obiektów tego samego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&amp;lt; T &amp;gt;&lt;/strong&gt; - kolekcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;first-in-first-out&lt;/em&gt; z elementami tego samego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt; - kolekcja par klucz/wartość tego samego typu które są sortowane wg klucza.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&amp;lt; T &amp;gt;&lt;/strong&gt; - kolekcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;last-in-first-out&lt;/em&gt; z elementami tego samego typu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcje generyczne są bardziej wydajne i powinno się ich używać jeżeli to możliwe.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Dictionary&amp;lt;TKey, TValue&amp;gt;&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt; pozwala na przechowywanie zbioru elementów, gdzie każdy element jest skojarzony kluczem. Zamiast indeksu do pobrania elementu z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt; używa się klucza. Może to być przydatne np do przechowywania elementów tabeli bazy danych gdzie kluczem może zostać identyfikator. &lt;br /&gt;Poniższy kod tworzy klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;MyRecord&lt;/em&gt; reprezentującą rekord w tabeli, która ma trzy kolumny. Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt; jest użyta do przechowania wielu elementów tej klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; MyRecord&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; ID { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; FirstName { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; LastName { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Sample1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    Dictionary&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;, MyRecord&amp;gt; myDictionary = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;, MyRecord&amp;gt;();&lt;br /&gt;&lt;br /&gt;    myDictionary.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyRecord() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;,&lt;br /&gt;        FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt;,&lt;br /&gt;        LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    myDictionary.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyRecord() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;,&lt;br /&gt;        FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;,&lt;br /&gt;        LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    myDictionary.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; MyRecord() { ID = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;,&lt;br /&gt;        FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bill"&lt;/span&gt;,&lt;br /&gt;        LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    Debug.WriteLine(myDictionary[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;].FirstName);&lt;br /&gt;    Debug.WriteLine(myDictionary[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;].FirstName);&lt;br /&gt;    Debug.WriteLine(myDictionary[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;].FirstName);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Bob &lt;br /&gt;Jane &lt;br /&gt;Bill&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Liczbę elementów kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt; uzyskujemy używając właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Count&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej używane metody kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; - dodaje klucz i wartość do słownika.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; - usuwa wszystkie elementy kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContainsKey&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli kolekcja zawiera określony klucz.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContainsValue&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli kolekcja zawiera określoną wartość.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Remove&lt;/strong&gt; - usuwa element określony kluczem.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli odwołujemy się do elementy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt; wg klucza który nie istnieje to wyrzucony zostaje wyjątek. Dobrą praktyką jest używanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContainsKey&lt;/strong&gt; zanim pobierzemy element wg klucza.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;List&amp;lt; T &amp;gt;&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;List&lt;/strong&gt; jest silnie typowaną kolekcją obiektów. Jest podobna do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; z wyjątkiem tego, że wszystkie elementy musza posiadać ten sam typ.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod tworzy listę liczb całkowitych i dodaje do niej trzy elementy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;List&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;&amp;gt; myList = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;&amp;gt;();&lt;br /&gt;&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;);&lt;br /&gt;myList.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&amp;lt; T &amp;gt;&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&amp;lt; T &amp;gt;&lt;/strong&gt; są silnie typowanymi odpowiednikami kolekcji z przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Kolekcje niestandardowe&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Oprócz standardowych kolekcji dostarczonych przez .NET, można tworzyć własne silnie typowane kolekcje. Silnie typowane kolekcje są użyteczne ponieważ nie ponoszą strat wydajnościowych spowodowanych przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;boxing&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;unboxing&lt;/em&gt;. Aby utworzyć własną kolekcję należy dziedziczyć z klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CollectionBase&lt;/strong&gt;. &lt;br /&gt;Najczęściej używane właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.CollectionBase&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Capacity&lt;/strong&gt; - pobiera lub ustawia liczbę elementów jaką może posiadać kolekcja.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Count&lt;/strong&gt; - zwraca liczbę elementów kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InnerList&lt;/strong&gt; - zwraca kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt; elementów w kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;List&lt;/strong&gt; - zwraca kolekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IList&lt;/strong&gt; elementów w kolekcji.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej używane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.CollectionBase&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clear&lt;/strong&gt; - czyści elementy z kolekcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnInsert&lt;/strong&gt; - umożliwia wykonanie niestandardowego przetwarzania przed wstawieniem nowego elementu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnRemove&lt;/strong&gt; - umożliwia wykonanie niestandardowego przetwarzania przed usunięciem elementu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnSet&lt;/strong&gt; - umożliwia wykonanie niestandardowego przetwarzania przed ustawieniem wartości elementu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RemoveAt&lt;/strong&gt; - usuwa element na pozycji określonej indeksem.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowo utworzymy kolekcję niestandardową zawierającą elementy typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;. Klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; wygląda następująco:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; PersonId { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Address { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; City { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; State { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; ZipCode { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Utwórzmy teraz kolekcję niestandardową dziedziczącą z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CollectionBase&lt;/strong&gt;. Poniższa kolekcja będzie posiadała metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Add&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Insert&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Remove&lt;/em&gt; oraz będzie posiadała silnie typowany &lt;em style="box-sizing: border-box; outline: none !important;"&gt;indexer&lt;/em&gt;. Indexer jest używany kiedy chcemy odnieść się do elementów kolekcji używając indeksu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;PersonCollection&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;CollectionBase&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Person person&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        List.Add(person);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Insert&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; index, Person person&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        List.Insert(index, person);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Remove&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Person person&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        List.Remove(person);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; Person &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; index]&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; (Person)List[index];&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            List[index] = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użycia niestandardowej kolekcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;PersonCollection&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    PersonCollection persons = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; PersonCollection();&lt;br /&gt;&lt;br /&gt;    persons.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person() {&lt;br /&gt;        PersonId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;,&lt;br /&gt;        FName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;,&lt;br /&gt;        LName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    persons.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person()&lt;br /&gt;    {&lt;br /&gt;        PersonId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;,&lt;br /&gt;        FName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;,&lt;br /&gt;        LName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    persons.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person()&lt;br /&gt;    {&lt;br /&gt;        PersonId = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;,&lt;br /&gt;        FName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bill Jones"&lt;/span&gt;,&lt;br /&gt;        LName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;    foreach (Person person in persons)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(person.FName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Konsumowanie danych&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Sekcja ta opisuje jak pobierać dane z bazy danych za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Service&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Praca z ADO.NET&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt; jest zestawem klas w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; które pozwalaja na połączenie z bazą danych oraz wykonanie na niej operacji. &lt;br /&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt; są zlokalizowane w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data&lt;/strong&gt;. W przestrzeni te znajduje się wiele klas bazowych i interfejsów które trzeba zaimplementować aby połączyć się z odpowiednim dostawcą danych. Przykładowo przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.SqlClient&lt;/strong&gt; zawiera zestaw klas i interfejsów do połączenia z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Connection&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Connection&lt;/strong&gt; jest używany do uzyskania połączenia z bazą danych. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlConnection&lt;/strong&gt; jest używana do połączenia z bazą danych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt;. Każda dostarczane przez różnych dostawców muszą dziedziczyć z klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Data.Common.DBConnection&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej używane właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBConnection&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConnectionString&lt;/strong&gt; - pobiera lub ustawia ciąg znaków używany do połączenia z bazą danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConnectionTimeout&lt;/strong&gt; - pobiera czas w sekundach, który system powinien czekać podczas nawiązywania połączenia z bazą danych przed wygenerowaniem błędu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Database&lt;/strong&gt; - pobiera nazwę bazy danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSource&lt;/strong&gt; - pobiera nazwę serwera.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ServerVersion&lt;/strong&gt; - pobiera wersję serwera dla bazy danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;State&lt;/strong&gt; - pobiera ciąg znaków reprezentujący stan połączenia z bazą danych np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Open&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Closed&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najważniejszą właściwością jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConnectionString&lt;/strong&gt;. Dla bazy danych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt; przyjmuje on następującą formę:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej używane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBConnection&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BeginTransaction&lt;/strong&gt; - rozpoczyna transakcję w bazie danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Close&lt;/strong&gt; - zamyka połączenie z bazą danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetSchema&lt;/strong&gt; - zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; zawierający informacje o schemacie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Open&lt;/strong&gt; - otwiera połączenie z bazą danych używając ciągu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConnectionString&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Open&lt;/strong&gt; otwiera połączenie z bazą danych. Po uzyskaniu połączenia możemy używać innych obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt; służących do wykonywania operacji na bazie danych. &lt;br /&gt;Poniższy kod tworzy połączenie z bazą danych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;&lt;/span&gt;    User Id=myUsername;Password=myPassword;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Open();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Command&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Command&lt;/strong&gt; jest używany do wykonywania operacji na bazie danych. Za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Command&lt;/strong&gt; można wykonać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;select&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;insert&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;update&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;delete&lt;/strong&gt; lub procedurę składowaną. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.Common.DBCommand&lt;/strong&gt; jest klasą bazową dla wszystkich klas dostawców. Klasa&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.SqlClient.SqlCommand&lt;/strong&gt; jest implementacją &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Command&lt;/strong&gt; dla bazy danych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metoda ExecuteNonQuery&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteNonQuery&lt;/strong&gt; jest używana do wykonywania wyrażenia na bazie danych które nie zwraca wyniku. Przykładowo instrukcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;insert&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;update&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;delete&lt;/em&gt;. &lt;br /&gt;Poniższy kod demonstruje użycie instrukcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;insert&lt;/em&gt; na tabeli bazy danych:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;&lt;/span&gt;    User Id=myUsername;Password=myPassword;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Open();&lt;br /&gt;&lt;br /&gt;SqlCommand cmd = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlCommand();&lt;br /&gt;cmd.Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;;&lt;br /&gt;cmd.CommandType = CommandType.Text;&lt;br /&gt;cmd.CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"INSERT INTO Person (FirstName, LastName) "&lt;/span&gt; +&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"VALUES ('Joe', 'Smith')"&lt;/span&gt;;&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przed wykonaniem metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteNonQuery&lt;/strong&gt; należy ustawić trzy właściwości obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlCommand&lt;/strong&gt;. Pierwszą jest właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Connectiod&lt;/strong&gt; która musi być ustawiona na otwarte połączenie z bazą danych. Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandType&lt;/strong&gt; posiada w tym przykładzie wartość&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandType.Text&lt;/strong&gt; ponieważ używamy instrukcji w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt;. Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandText&lt;/strong&gt; zawiera kod &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt; który chcemy wykonać.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli chcemy wykonać procedurę składowaną to należy ustawić właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandType&lt;/strong&gt; na &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandType.StoredProcedure&lt;/strong&gt; oraz ustawić właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandText&lt;/strong&gt; na nazwę procedury.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowo utwórzmy procedurę składowaną w bazie danych w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;T-SQL&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CREATE&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;PROCEDURE&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;PersonInsert&lt;/span&gt;&lt;br /&gt;    @&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;FirstName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;varchar&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(50)&lt;/span&gt;,&lt;br /&gt;    @&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;LastName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;varchar&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(50)&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;INSERT&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;INTO&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;PERSON&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(FirstName, LastName)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;VALUES&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(@FirstName, @LastName)&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod wykonuje procedurę składowaną i wstawia do niej parametry:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;&lt;/span&gt;    User Id=myUsername;Password=myPassword;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Open();&lt;br /&gt;&lt;br /&gt;SqlCommand cmd = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlCommand();&lt;br /&gt;cmd.Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;;&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;cmd.CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PersonInsert"&lt;/span&gt;;&lt;br /&gt;cmd.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@FirstName"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Joe"&lt;/span&gt;));&lt;br /&gt;cmd.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@LastName"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;));&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Command&lt;/strong&gt; posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Parameters&lt;/strong&gt; która jest używana do wstawiania parametrów do procedur składowanych. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteNonQuery&lt;/strong&gt; zwraca w wyniku liczbę wierszy które zostały zmienione przez wykonanie zapytania.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metoda ExecuteReader&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteReader&lt;/strong&gt; używa się aby pobrać dane z bazy danych np za pomocą instrukcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;select&lt;/em&gt;. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteReader&lt;/strong&gt; zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; jest zdefiniowana w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt; i służy do pobierania wyników podczas gdy obiekt jest połączony z bazą danych. Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; jest obiektem typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;forward-only&lt;/em&gt; co oznacza, że możemy przechodzić przez rekord wynikowy raz i nie możemy cofnąć kursora do poprzedniej pozycji.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod wyświetla wszystkie rekordy tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; za pomocą obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlDataReader&lt;/strong&gt; który jest implementacją &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; dla bazy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL Server&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;SqlConnection&lt;/span&gt; cn = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;SqlConnection&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;cn.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ConnectionString&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;    User Id=myUsername;Password=myPassword;"&lt;/span&gt;;&lt;br /&gt;cn.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Open&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;SqlCommand&lt;/span&gt; cmd = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;SqlCommand&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;cmd.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Connection&lt;/span&gt; = cn;&lt;br /&gt;cmd.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;CommandType&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;CommandType&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Text&lt;/span&gt;;&lt;br /&gt;cmd.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;CommandText&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"SELECT * FROM Person"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;SqlDataReader&lt;/span&gt; dr = cmd.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ExecuteReader&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (dr.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;HasRows&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (dr.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Read&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Debug&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Format&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"First Name: {0} , Last Name: {1}"&lt;/span&gt;,&lt;br /&gt;            dr[&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;], dr[&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;]));&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;dr.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Close&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;cn.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Close&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Po zakończeniu odczytu należy zamknąć obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; a następnie obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Connection&lt;/strong&gt;. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteReader&lt;/strong&gt; posiada przeciążenie z parametrem typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandBehavior&lt;/strong&gt; pozwalające na automatyczne zamykanie połączenia po zakończeniu odczytu.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Drugą metodą zamykania połączenia w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; jest użycie bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;. Jest to zalecana metoda używania połączeń. &lt;br /&gt;Składnia użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; z obiektem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Connection&lt;/strong&gt; wygląda następująco:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (SqlConnection cn = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection())&lt;br /&gt;{&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej wykorzystywane właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FieldCount&lt;/strong&gt; - zwraca liczbę kolumn aktualnego wiersza.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HasRows&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; posiada jakiekolwiek wiersze.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsClosed&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; jest zamknięty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Item[Int32]&lt;/strong&gt; - jest to indekser zwracający kolumnę bazując na indeksie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Item[String]&lt;/strong&gt; - jest to indekser zwracający kolumnę bazując na jej nazwie.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Nie istnieje właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Count&lt;/strong&gt; dla obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;. Aby dowiedzieć się ile jest wierszy w wyniku należy przejść przez wszystkie wiersze obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ważną rzeczą jest zapamiętanie, że dla kolumny zawierającej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt; obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; zwraca wartość typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBNull.Value&lt;/strong&gt; a nie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej wykorzystywane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Close&lt;/strong&gt; - zamyka obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetBoolean&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;bool&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetByte&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;byte&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetChar&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;char&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetDateTime&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DateTime&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetDecimal&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;decimal&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetDouble&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;double&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFieldType&lt;/strong&gt; - zwraca typ danych wybranej kolumny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFieldValue&lt;/strong&gt; - zwraca wartość wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;T&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFloat&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;float&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetGuid&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Guid&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetInt16&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Int16&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetInt32&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Int32&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetInt64&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Int64&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetName&lt;/strong&gt; - zwraca nazwę wybranej kolumny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetOrdinal&lt;/strong&gt; - zwraca pozycję wybranej kolumny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetSchemaTable&lt;/strong&gt; - zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; zawierający metadane kolumn.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetString&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetValue&lt;/strong&gt; - zwraca wynik wybranej kolumny jako typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;object&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetValues&lt;/strong&gt; - wypełnia tablicę obiektów wartościami kolumn.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NextResult&lt;/strong&gt; - przenosi kursor do następnego wyniku w obiekcie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsDBNull&lt;/strong&gt; - sprawdza czy wynik zawiera wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - przesuwa kursor do następnego rekordu jeżeli rekord istnieje.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dobrą praktyką jest sprawdzenie właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HasRows&lt;/strong&gt; przed użyciem metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; ponieważ metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; zgłosi wyjątek jeżeli nie będzie następnego rekordu w obiekcie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pobierając dane z bazy danych można wykonać kilka instrukcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Select&lt;/em&gt; w jednym wywołaniu. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; potrafi przechowywać wiele wyników w jednym obiekcie. Aby przenieść się do następnego wyniku używamy metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NextResult&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetSchemaTable&lt;/strong&gt; zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; zawierający metadane kolumn w obiekcie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt;. Zwrócona tabela posiada wiersz dla każdej kolumny i zawiera nazwę kolumny, typ, rozmiar, pozycję porządkową, informację czy jest to kolumna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Identity&lt;/em&gt; oraz czy zezwala na wartości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;. Jeżeli chcemy pobrać tylko metadane dla tabeli to możemy wykonać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteDataReader&lt;/strong&gt; z parametrem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CommandBehavior.SchemaOnly&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metoda ExecuteScalar&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteScalar&lt;/strong&gt; używamy kiedy wiemy, że wynik zapytania do bazy danych zwróci tylko jeden wynik tzn jedną kolumnę z jednym wierszem. &lt;br /&gt;Poniższy kod wywołuje metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteScalar&lt;/strong&gt; i zwraca liczbę wierszy w tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;&lt;/span&gt;    User Id=myUsername;Password=myPassword;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Open();&lt;br /&gt;&lt;br /&gt;SqlCommand cmd = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlCommand();&lt;br /&gt;cmd.Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;;&lt;br /&gt;cmd.CommandType = CommandType.Text;&lt;br /&gt;cmd.CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"SELECT COUNT(*) FROM Person"&lt;/span&gt;;&lt;br /&gt;object obj = cmd.ExecuteScalar();&lt;br /&gt;&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Count: {0}"&lt;/span&gt;, obj.ToString()));&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteScalar&lt;/strong&gt; zawsze zwraca wynik typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;object&lt;/strong&gt; który możemy rzutować do odpowiedniego typu wyniku.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metoda ExecuteXmlReader&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteXmlReader&lt;/strong&gt; zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XmlReader&lt;/strong&gt;, który pozwala zaprezentować dane jako &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;. &lt;br /&gt;Poniższy kod zwraca dane z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; w postaci &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XmlReader&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;    User Id=myUsername;Password=myPassword;"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Open();&lt;br /&gt;&lt;br /&gt;SqlComm&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;and&lt;/span&gt; cmd = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; SqlComm&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;and&lt;/span&gt;();&lt;br /&gt;cmd&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;;&lt;br /&gt;cmd&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;CommandType = CommandType&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Text;&lt;br /&gt;cmd&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"SELECT * FROM Person FOR XML AUTO, XMLDATA"&lt;/span&gt;;&lt;br /&gt;System&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Xml&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;XmlReader &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;xml&lt;/span&gt; = cmd&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;ExecuteXmlReader();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik zapytania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&amp;lt;Schema name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Schema1"&lt;/span&gt; xmlns=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"urn:schemas-microsoft-com:xml-data"&lt;/span&gt;&lt;br /&gt; xmlns:dt=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"urn:schemas-microsoft-com:datatypes"&lt;/span&gt;&amp;gt;&lt;br /&gt;    &amp;lt;ElementType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person"&lt;/span&gt; content=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"empty"&lt;/span&gt; model=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"closed"&lt;/span&gt;&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PersonId"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"i4"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"string"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"string"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Address"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"string"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"City"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"string"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"State"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"string"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;AttributeType name=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ZipCode"&lt;/span&gt; dt:&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"string"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PersonId"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Address"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"City"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"State"&lt;/span&gt;/&amp;gt;&lt;br /&gt;        &amp;lt;attribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;type&lt;/span&gt;&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ZipCode"&lt;/span&gt;/&amp;gt;&lt;br /&gt;    &amp;lt;/ElementType&amp;gt;&lt;br /&gt;&amp;lt;/Schema&amp;gt;&lt;br /&gt;&amp;lt;Person xmlns=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"x-schema:#Schema1"&lt;/span&gt; PersonId=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"1"&lt;/span&gt; FirstName=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt; LastName=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;&lt;br /&gt; Address=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"123 First Street"&lt;/span&gt; City=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Philadelphia"&lt;/span&gt; State=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PA"&lt;/span&gt; ZipCode=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"19111"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;DataSet, DataTable i DataAdapter&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Innym sposobem na pobranie danych z bazy danych jest użycie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt;. Możliwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; są podobne do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; , poza tym , że &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; jest odłączona od bazy danych, można poruszać się kursorem w przód i w tył oraz można aktualizować dane, połączyć się ponownie do bazy danych i zapisać zmiany. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; jest kontenerem dla jednego lub wielu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt;. Można wykonać instrukcję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt; która zwróci wiele wyników i każdy z nich będzie zawarty w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt;. Można wtedy filtrować, sortować i aktualizować te dane w pamięci. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataAdapter&lt;/strong&gt; służy do wypełnienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; oraz ponownego połączenia z bazą danych aby wykonać komendę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;insert&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;update&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;delete&lt;/em&gt;. &lt;br /&gt;Poniższy kod używa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; do pobrania danych z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; i ich wyświetlenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;    User Id=myUsername;Password=myPassword;"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Open();&lt;br /&gt;&lt;br /&gt;SqlDataAdapter da = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; SqlDataAdapter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"SELECT * FROM Person"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;);&lt;br /&gt;DataSet ds = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; DataSet();&lt;br /&gt;da&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Fill(ds, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;cn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Close();&lt;br /&gt;&lt;br /&gt;foreach (DataRow row &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; ds&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Tables&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;]&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;.Rows)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(string.Format("First Name: {0} , Last Name: {1}",&lt;br /&gt;        row&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;]&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;, row&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;]&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;));&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Fill&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlDataAdapter&lt;/strong&gt; służy do wypełnienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt;. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Tables&lt;/strong&gt; której można uzyć aby odwołać się do obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; które zostały zwrócone przez zapytanie. W powyższym przykładzie powstał tylko jeden obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; więc można się do niego odwołać poprzez indeks o wartości zero. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rows&lt;/strong&gt;, zawierającą kolekcję obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataRow&lt;/strong&gt; które reprezentują zwrócone rekordy. Do rekordów można odwołać się poprzez indeks lub iterując kolekcję. Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rows&lt;/strong&gt; posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Count&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataAdapter&lt;/strong&gt; pozwala na wstawianie, aktualizowanie i usuwanie wierszy po zmianie obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt;. Poniższy przykład pokazuje jak użyć obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataAdapter&lt;/strong&gt; do wstawiania rekordów do bazy danych:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;&lt;/span&gt;    User Id=myUsername;Password=myPassword;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Open();&lt;br /&gt;&lt;br /&gt;SqlDataAdapter da = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlDataAdapter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"SELECT * FROM Person"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;//Create the &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;command&lt;/span&gt;&lt;br /&gt;SqlCommand &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlCommand();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;.Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;.CommandType = CommandType.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;.CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"INSERT INTO Person (FirstName, LastName) VALUES (@FirstName,&lt;br /&gt;&lt;/span&gt;    @LastName)&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;//Create the parameters&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@FirstName"&lt;/span&gt;, SqlDbType.VarChar, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;50&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@LastName"&lt;/span&gt;, SqlDbType.VarChar, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;50&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;//Associate the &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;command&lt;/span&gt; with the DataAdapter.&lt;br /&gt;da.InsertCommand = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;insert&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;//Get the data.&lt;br /&gt;DataSet &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; DataSet();&lt;br /&gt;da.Fill(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;//Add &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;a&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; row.&lt;br /&gt;DataRow newRow = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;].NewRow();&lt;br /&gt;newRow[&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jane"&lt;/span&gt;;&lt;br /&gt;newRow[&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Doe"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;].Rows.Add(newRow);&lt;br /&gt;&lt;br /&gt;//Update the database.&lt;br /&gt;da.Update(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;]);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod demonstruje jak użyć obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataAdapter&lt;/strong&gt; do aktualizacji i usuwania rekordów bazy danych:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;SqlConnection &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlConnection();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.ConnectionString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Server=myServerAddress;Database=myDataBase;&lt;br /&gt;&lt;/span&gt;    User Id=myUsername;Password=myPassword;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Open();&lt;br /&gt;&lt;br /&gt;SqlDataAdapter da = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlDataAdapter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"SELECT * FROM Person"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;//Create the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;command&lt;/span&gt;&lt;br /&gt;SqlCommand &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlCommand();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;.Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;.CommandType = CommandType.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;.CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"UPDATE Person SET FirstName = @FirstName, LastName = @LastName&lt;br /&gt;&lt;/span&gt;    WHERE PersonId = @PersonId&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;//Create the parameters&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@FirstName"&lt;/span&gt;, SqlDbType.VarChar, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;50&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@LastName"&lt;/span&gt;, SqlDbType.VarChar, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;50&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;.Parameters.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@PersonId"&lt;/span&gt;, SqlDbType.Int, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PersonId"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;//Create the &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;command&lt;/span&gt;&lt;br /&gt;SqlCommand &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlCommand();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt;.Connection = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt;.CommandType = CommandType.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt;.CommandText = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"DELETE FROM Person WHERE PersonId = @PersonId"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;//Create the parameters&lt;br /&gt;SqlParameter deleteParameter = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; SqlParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"@PersonId"&lt;/span&gt;, SqlDbType.Int, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"PersonId"&lt;/span&gt;);&lt;br /&gt;deleteParameter.SourceVersion = DataRowVersion.Original;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt;.Parameters.Add(deleteParameter);&lt;br /&gt;&lt;br /&gt;//Associate the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;and&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt; commands with the DataAdapter.&lt;br /&gt;da.UpdateCommand = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;update&lt;/span&gt;;&lt;br /&gt;da.DeleteCommand = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delete&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;//Get the data.&lt;br /&gt;DataSet &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; DataSet();&lt;br /&gt;da.Fill(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;//Update the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;first&lt;/span&gt; row&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;].Rows[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;][&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName"&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jack"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;].Rows[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;][&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName"&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Johnson"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;//Delete the second row.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;].Rows[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;].Delete();&lt;br /&gt;&lt;br /&gt;//Updat the database.&lt;br /&gt;da.Update(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ds&lt;/span&gt;.Tables[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;]);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;cn&lt;/span&gt;.Close();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Praca z Entity Framework&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Biblioteka &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Entity Framework&lt;/strong&gt; jest zestawem klas który również umożliwia wykonywanie operacji na bazie danych. Ponadto &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; posiada interfejs graficzny pozwalający na przeciąganie i upuszczanie obiektów bazy danych na powierzchnię projektową. Biblioteka&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Entity Framework&lt;/strong&gt; jest narzędziem zwanym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ORM&lt;/strong&gt; (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Object-Relational Mapping&lt;/em&gt;). &lt;br /&gt;Przykłady tej sekcji będą używały bazy danych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Northwind&lt;/em&gt; dostępnej pod adresem &lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="http://northwinddatabase.codeplex.com/" target="_blank"&gt;http://northwinddatabase.codeplex.com/&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Tworzenie modelu Entity Framework w Visual Studio&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Rdzeniem pracy z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; jest model. Model zawiera wszystkie klasy które reprezentują obiekty w bazie danych. &lt;br /&gt;Aby utworzyć model bazy danych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Northwind&lt;/em&gt; należy:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Uruchomić &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Utworzyć nowy projekt np typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Console Application&lt;/em&gt; i nadać mu nazwę np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsConsole&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Po utworzeniu dodać nowy element z menu rozwijanego w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Solution Explorer&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodać &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ADO.NET Entity Data Model&lt;/em&gt; z listy zainstalowanych szablonów i nadać mu nazwę np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsModel&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Ponieważ baza danych już istnieje wybieramy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Generate from Database&lt;/em&gt;. Takie podejście tworzenia modelu nazywane jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Database First&lt;/em&gt;. Alternatywnym podejściem jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Model First&lt;/em&gt;, które pozwala na wygenerowanie bazy danych po utworzeniu klas modelu danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W oknie połączenia z bazą danych należy wybrać nowe połączenie z danymi łączącymi z bazą danych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Northwind&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Po wybraniu połączenia należy wybrać obiekty które mają być zmapowane w modelu. Wybieramy tabele, widoki i procedury składowane.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Generator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; wygeneruje model który będzie wyglądał tak: &lt;br /&gt;&lt;img longdesc="./1454704118436.png" style="box-sizing: border-box; outline: none !important; border: 0px; vertical-align: middle; max-width: 100%;" alt="Alt text" /&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Do projektu został dodany plik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NorthwindsModel.edmx&lt;/strong&gt;, jest to graficzna reprezentacja modelu. Klikając strzałkę przy nazwie modelu w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Solution Explorer&lt;/em&gt; możemy zobaczyć wszystkie klasy jakie zostały wygenerowane dla modelu.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Plik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NorthwindsModel.tt&lt;/strong&gt; jest plikiem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Text Transformation Template Toolkit&lt;/em&gt; zwanym również szablonem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T4&lt;/strong&gt;. Szablony &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T4&lt;/strong&gt; są używane do automatycznego generowania kodu w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt;. Klikając strzałkę obok pliku zobaczymy listę wygenerowanych przez model klas. jak widać dla każdej tabeli, widoku i procedury został wygenerowany osobny plik. &lt;br /&gt;Przykładowo plik &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Categories.cs&lt;/em&gt; jest plikiem klasy wygenerowanej dla tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Category&lt;/em&gt; i ma następującą postać:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;partial&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Categories&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Categories&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Products = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; HashSet&amp;lt;Products&amp;gt;();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; CategoryID { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; CategoryName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Description { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;byte&lt;/span&gt;[] Picture { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;virtual&lt;/span&gt; ICollection&amp;lt;Products&amp;gt; Products { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dla każdej kolumny została wygenerowana właściwość. Została również wygenerowana inna właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ICollection Products&lt;/strong&gt; która jest wygenerowaną kolekcją dla tabeli połączonej kluczem obcym.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Plik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NorthwindsModel.Context.tt&lt;/strong&gt; jest szablonem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T4&lt;/strong&gt; dla obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Context&lt;/strong&gt;. Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Context&lt;/strong&gt; jest obiektem który reprezentuje połączenie z całą bazą danych. Jeżeli rozwiniemy plik to zobaczymy plik &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsModel.Context.cs&lt;/em&gt; w którym zdefiniowana jest klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsEntities&lt;/em&gt;posiadająca właściwości dla każdej tabeli w bazie danych. Właściwości są typu generycznego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DbSet&lt;/strong&gt;, który jest kolekcją dla każdego typu reprezentującego tabelę lub widok np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; DbSet&amp;lt;Category&amp;gt; Categories { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Procedury składowane zostały stworzone jako metody o takiej samej nazwie. Parametry procedur są zmapowane na parametry tych metod. Jeżeli procedura zwraca wynik to metoda posiada typ zwracanej kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ObjectResult&lt;/strong&gt;. Przykładowo procedura &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CustOrderHist&lt;/em&gt; została zmapowana na następującą metodę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;virtual&lt;/span&gt; ObjectResult&amp;lt;CustOrderHist_Result&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;CustOrderHist&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; customerID&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; customerIDParameter = customerID != &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt; ?&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ObjectParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CustomerID"&lt;/span&gt;, customerID) :&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ObjectParameter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CustomerID"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; ((IObjectContextAdapter)&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;).ObjectContext.ExecuteFunction&lt;br /&gt;        &amp;lt;CustOrderHist_Result&amp;gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CustOrderHist"&lt;/span&gt;, customerIDParameter);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CustOrderHist_Result&lt;/em&gt; jest typem utworzonym dla zwracanych wartości procedury. procedura posiada jeden parametr zmapowany jako &lt;em style="box-sizing: border-box; outline: none !important;"&gt;customerID&lt;/em&gt;. Aby wywołać procedurę wykonywana jest metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteFunction&lt;/strong&gt; która jest zdefiniowana w klasie bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DbContext&lt;/strong&gt;. Klasa&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DbContext&lt;/strong&gt; jest zdefiniowana w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.Entity&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Pobieranie rekordów&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Posiadając model możemy pobrać dane nie znając języka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt; i posługując się jedynie obiektami. &lt;br /&gt;Poniższy fragment kodu pobiera rekordy z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Category&lt;/em&gt; i wyświetla je:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (NORTHWNDEntities db = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NORTHWNDEntities())&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; categories = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; c &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; db.Categories &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; c;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (Categories category &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; categories)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CategoryId: {0}, CategoryName: {1}"&lt;/span&gt;, &lt;br /&gt;            category.CategoryID, category.CategoryName));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania zapytania:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;CategoryId: 1, CategoryName: Beverages &lt;br /&gt;CategoryId: 2, CategoryName: Condiments &lt;br /&gt;CategoryId: 3, CategoryName: Confections &lt;br /&gt;CategoryId: 4, CategoryName: Dairy Products &lt;br /&gt;CategoryId: 5, CategoryName: Grains/Cereals &lt;br /&gt;CategoryId: 6, CategoryName: Meat/Poultry &lt;br /&gt;CategoryId: 7, CategoryName: Produce &lt;br /&gt;CategoryId: 8, CategoryName: Seafood&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Do pobierania danych z użyciem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; używane są zapytania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod demonstruje pobieranie danych z wielu tabel połączonych kluczem obcym:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (NORTHWNDEntities db = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NORTHWNDEntities())&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; products = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; c &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; db.Categories&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;join&lt;/span&gt; p &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; db.Products on c.CategoryID equals p.CategoryID&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; p;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (Products product &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; products)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ProductName: {0}, CategorName: {1}"&lt;/span&gt;, &lt;br /&gt;                product.ProductName, &lt;br /&gt;                product.Categories.CategoryName));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wstawianie rekordów&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu demonstruje wstawianie rekordu do tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Category&lt;/em&gt; za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (NORTHWNDEntities db = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NORTHWNDEntities())&lt;br /&gt;{&lt;br /&gt;    Categories category = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Categories() { &lt;br /&gt;        CategoryName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alcohol"&lt;/span&gt;, &lt;br /&gt;        Description = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Happy Beverages"&lt;/span&gt;&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    db.Categories.Add(category);&lt;br /&gt;    db.SaveChanges();&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Po utworzeniu instancji klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Categories&lt;/em&gt; została ona dodana do kolekcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;db.Categories&lt;/em&gt; za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt;. Zmiany w bazie danych zostały zapisane za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SaveChanges&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Aktualizacja rekordów&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu demonstruje aktualizację rekordu z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Category&lt;/em&gt; za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;using (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NORTHWNDEntities&lt;/span&gt; db = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NORTHWNDEntities&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Categories&lt;/span&gt; category = db.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Categories&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;First&lt;/span&gt;(c =&amp;gt; c.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;CategoryName&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alcohol"&lt;/span&gt;);&lt;br /&gt;    category.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Description&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Happy People"&lt;/span&gt;;&lt;br /&gt;    db.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;SaveChanges&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Usuwanie rekordów&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu demonstruje usuwanie rekordu z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Category&lt;/em&gt; za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;using (NORTHWNDEntities &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;db&lt;/span&gt; = new NORTHWNDEntities())&lt;br /&gt;{&lt;br /&gt;    Categories category = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;db&lt;/span&gt;.Categories.First(c =&amp;gt; c.CategoryName == &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alcohol"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;db&lt;/span&gt;.Categories.Remove(category);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;db&lt;/span&gt;.SaveChanges();&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W wersjach wcześniejszych niż &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework 5.0&lt;/strong&gt; usuwanie rekordów odbywało się z użyciem metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DeleteObject&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wywołanie procedury składowanej&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ procedury składowane są wygenerowane przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EF&lt;/strong&gt; jako metody to ich wywołanie oznacza proste wywołanie metody np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NORTHWNDEntities&lt;/span&gt; db = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NORTHWNDEntities&lt;/span&gt;())&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; custOrderHist = db.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;CustOrderHist&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ALFKI"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;CustOrderHist_Result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; custOrderHist)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Debug&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Format&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ProductName: {0}, Total: {1}"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ProductName&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Total&lt;/span&gt;));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;WCF Data Services&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Services&lt;/strong&gt; są komponentami &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; które umożliwiają dostęp do bazy danych poprzez użycie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;URI&lt;/em&gt;. W poprzednich wersjach usługa ta nazywała się &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Data Services&lt;/strong&gt;. Używając &lt;em style="box-sizing: border-box; outline: none !important;"&gt;URI&lt;/em&gt; i ich parametrów można pobierać, filtrować, aktualizować a nawet usuwać dane. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Services&lt;/strong&gt; używają &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Open Data Protocol&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OData&lt;/strong&gt;), który jest protokołem sieciowym używającym &lt;em style="box-sizing: border-box; outline: none !important;"&gt;HTTP&lt;/em&gt;. &lt;br /&gt;Przykładowo poniższy adres może być użyty do pobrania przefiltrowanych kategorii z bazy danych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Northwind&lt;/em&gt;:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;&lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories?$filter=CategoryName" target="_blank"&gt;http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories?$filter=CategoryName&lt;/a&gt; eq ‘Beverages’&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W powyższym przykładzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Categories&lt;/strong&gt; to encja która ma być zwrócona a parametr &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;filter&lt;/strong&gt; jest użyty do znalezienia kategorii które mają pole &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CategoryName&lt;/strong&gt; równe &lt;em style="box-sizing: border-box; outline: none !important;"&gt;‘Beverages’&lt;/em&gt;. Dane mogą być zwracane w formacie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XML&lt;/strong&gt; (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;OData ATOM Format&lt;/em&gt;) lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;JSON&lt;/strong&gt;. &lt;br /&gt;Powyższe zapytanie zwraca wynik w postaci &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XML&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;feed&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;xml:base&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"http://localhost:5000/WcfDataService1.svc/"&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;xmlns&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;http:&lt;/span&gt;//&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;www.w3.org&lt;/span&gt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;2005&lt;/span&gt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Atom&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;xmlns:d&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;http:&lt;/span&gt;//&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;schemas.microsoft.com&lt;/span&gt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ado&lt;/span&gt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;2007&lt;/span&gt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;08&lt;/span&gt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;dataservices&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;xmlns:m&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;id&lt;/span&gt;&amp;gt;&lt;/span&gt;http://localhost:5000/WcfDataService1.svc/Categories&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;id&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;title&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;type&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"text"&lt;/span&gt;&amp;gt;&lt;/span&gt;Categories&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;title&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;updated&lt;/span&gt;&amp;gt;&lt;/span&gt;2013-01-01T23:54:24Z&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;updated&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;link&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;rel&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"self"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;title&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"Categories"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;href&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"Categories"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;entry&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;id&lt;/span&gt;&amp;gt;&lt;/span&gt;http://localhost:5000/WcfDataService1.svc/Categories(1)&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;id&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;category&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;term&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"NorthwindsModel.Category"&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;scheme&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;link&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;rel&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"edit"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;title&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"Category"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;href&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"Categories(1)"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;title&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;updated&lt;/span&gt;&amp;gt;&lt;/span&gt;2013-01-10T23:54:24Z&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;updated&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;author&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;name&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;author&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;content&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;type&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"application/xml"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;m:properties&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:CategoryID&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;m:type&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"Edm.Int32"&lt;/span&gt;&amp;gt;&lt;/span&gt;1&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:CategoryID&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:CategoryName&lt;/span&gt;&amp;gt;&lt;/span&gt;Beverages&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:CategoryName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:Description&lt;/span&gt;&amp;gt;&lt;/span&gt;Soft drinks, coffees, teas, beers, and ales&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:Description&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:Picture&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;m:type&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"Edm.Binary"&lt;/span&gt;&amp;gt;&lt;/span&gt;FRwvA…&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d:Picture&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;m:properties&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;content&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;entry&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;feed&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Tworzenie WCF Data Service&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Utworzenie serwisu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Service&lt;/strong&gt; polega na utworzeniu aplikacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WEB&lt;/em&gt;, utworzeniu modelu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; i wyeksponowanie tego modelu dodając &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Service&lt;/strong&gt;:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodaj pusty projekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ASP.NET Web Application&lt;/strong&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; i nazwij go &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsWCFDataService&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodaj do projektu model &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Entity Data Model&lt;/strong&gt; dla bazy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Northwind&lt;/strong&gt; z nazwą &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsModel&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodaj do projektu serwis &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Service&lt;/strong&gt; i nazwij go &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsService.svc&lt;/em&gt;. Spowoduje to wygenerowanie następującej klasy dziedziczącej z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataService&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;WCF_Data_Service&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DataService&lt;/span&gt;&amp;lt; /* &lt;span style="box-sizing: border-box; outline: none !important;"&gt;TODO&lt;/span&gt;: put your data source class name here */ &amp;gt;&lt;br /&gt;{&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;This&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;is&lt;/span&gt; called only once to initialize service-wide policies.&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InitializeService&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;DataServiceConfiguration&lt;/span&gt; config)&lt;br /&gt;    {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;TODO&lt;/span&gt;: &lt;span style="box-sizing: border-box; outline: none !important;"&gt;set&lt;/span&gt; rules to indicate which entity sets &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;and&lt;/span&gt; service operations are visible, updatable, etc.&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Examples&lt;/span&gt;:&lt;br /&gt;        // config.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;SetEntitySetAccessRule&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"MyEntityset"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;EntitySetRights&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;AllRead&lt;/span&gt;);&lt;br /&gt;        // config.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;SetServiceOperationAccessRule&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"MyServiceOperation"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ServiceOperationRights&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;All&lt;/span&gt;);&lt;br /&gt;        config.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;DataServiceBehavior&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MaxProtocolVersion&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DataServiceProtocolVersion&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;V3&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;ol start="4" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zamień tekst &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TODO&lt;/em&gt; na nazwę modelu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Data Model&lt;/strong&gt; czyli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsEntities&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodaj poniższą linię kodu do metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;InitializeService&lt;/em&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;config&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.SetEntitySetAccessRule&lt;/span&gt;("&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Categories&lt;/span&gt;", &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;EntitySetRights&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.AllRead&lt;/span&gt; );&lt;/pre&gt;
&lt;ol start="6" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Uruchom projekt i otwórz adres w przeglądarce: &lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories" target="_blank"&gt;http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Serwisy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Service&lt;/strong&gt; pozwalają na używanie następujących opcji zapytań:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$orderby&lt;/strong&gt; - ustawia sortowanie np &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;$orderby=CategoryName,CategoryId&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$top&lt;/strong&gt; - ustawia limit pobierania danych np &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;$top=10&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$skip&lt;/strong&gt; - ustawia liczbę rekordów wynikowych do pominięcia np &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;$skip=10&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt; - definiuje wyrażenie filtrujące dane np &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;?$filter=CategoryName eq ‘Beverages’&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$expand&lt;/strong&gt; - określa które powiązane encje mają być zawarte w wyniku np &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;$expand=Products&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$select&lt;/strong&gt; - określa kolumny zwracane w wyniku np: &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;$select=CategoryName,CategoryId&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$inlinecount&lt;/strong&gt; - zwraca liczbę wierszy wyniku&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista operatorów używanych w opcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Eq&lt;/strong&gt; - równe&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Ne&lt;/strong&gt; - nierówne&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Gt&lt;/strong&gt; - większe niż&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Ge&lt;/strong&gt; - większe lub równe&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Lt&lt;/strong&gt; - mniejsze niż&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Le&lt;/strong&gt; - mniejsze lub równe&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;And&lt;/strong&gt; - logiczne &lt;em style="box-sizing: border-box; outline: none !important;"&gt;And&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Or&lt;/strong&gt; - logiczne &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Or&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Not&lt;/strong&gt; - logiczne &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Not&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;()&lt;/strong&gt; - nawias matematyczny określający pierwszeństwo&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; - dodawanie&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Sub&lt;/strong&gt; - odejmowanie&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Mul&lt;/strong&gt; - mnożenie&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Div&lt;/strong&gt; - dzielenie&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Mod&lt;/strong&gt; - reszta&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W opcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt; można również używać następujących funkcji dla ciągów znaków:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool substring(string p0, string p1)&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; jest w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p1&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool endswith(string p0, string p1)&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; zakończone jest ciągiem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p1&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool startswith(string p0, string p1)&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; zaczyna sie od &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p1&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int length(string p0)&lt;/strong&gt; - zwraca długość ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int indexof(string p0, string p1)&lt;/strong&gt; - zwraca pozycję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p1&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string replace(string p0, string p1, string replace)&lt;/strong&gt; - wyszukuje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p1&lt;/em&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; i zastępuje przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;replace&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string substring(string p0, int pos)&lt;/strong&gt; - zwraca podciąg &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; od pozycji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;pos&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string substring(string p0, int pospos, int length)&lt;/strong&gt; - zwraca podciąg &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; od pozycji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;pos&lt;/em&gt; o długości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;length&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string tolower(string p0)&lt;/strong&gt; - zwraca ciąg jako małe znaki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string toupper(string p0)&lt;/strong&gt; - zwraca ciąg jako duże znaki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string trim(string p0)&lt;/strong&gt; - zwraca ciąg bez białych znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string concat(string p0, string p1)&lt;/strong&gt; - łączy ciągi.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W opcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt; można również używać następujących funkcji dla dat:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int day(DateTime p0)&lt;/strong&gt; - zwraca dzień z daty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int hour(DateTime p0)&lt;/strong&gt; - zwraca godzinę z daty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int minute(DateTime p0)&lt;/strong&gt; - zwraca minuty z daty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int month(DateTime p0)&lt;/strong&gt; - zwraca miesiącz daty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int second(DateTime p0)&lt;/strong&gt; - zwraca sekundy z daty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int year(DateTime p0)&lt;/strong&gt; - zwraca rokz daty.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W opcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt; można również używać następujących funkcji matematycznych:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double round(double p0)&lt;/strong&gt; - zaokraglenie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;decimal round(double p0)&lt;/strong&gt; - zaokrąglenie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double floor(double p0)&lt;/strong&gt; - podłoga.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;decimal floor(double p0)&lt;/strong&gt; - podłoga.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double ceiling(double p0)&lt;/strong&gt; - powała.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;decimal ceiling(double p0)&lt;/strong&gt; - powała.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W opcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt; można również używać następujących funkcji typów:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool isOf(type p0)&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli encja jest typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool IsOf(expression p0, type p0)&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p0&lt;/em&gt; jest typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;p1&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poza używaniem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;$filter&lt;/strong&gt; można również pobierać encje używając klucza głównego w nawiasie okrągłym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;()&lt;/strong&gt; np&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;&lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories(1)" target="_blank"&gt;http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories(1)&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy adres &lt;em style="box-sizing: border-box; outline: none !important;"&gt;URI&lt;/em&gt; zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CategoryName&lt;/em&gt; tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Category&lt;/em&gt; z wartością klucza głównego równą 1:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;&lt;a style="box-sizing: border-box; outline: none !important; color: #1980e6; text-decoration: none; transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out; background: transparent;" rel="noopener" href="http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories(1)/CategoryName" target="_blank"&gt;http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories(1)/CategoryName&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Tworzenie aplikacji klienckiej używającej Uses WCF Data Services&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W tej sekcji utworzymy aplikację konsolową która będzie odnosić się do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Northwinds WCF Data Service&lt;/em&gt; i wykonywać operacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CRUD&lt;/em&gt; na danych:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodaj nowy projekt &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Console Application&lt;/em&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; o nazwie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsClient&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Solution Explorer&lt;/em&gt; kliknij prawym przyciskiem myszy na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;References&lt;/em&gt; i dodaj referencje do serwisu wybierając opcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add Service Reference&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Używając guzika &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Discover&lt;/em&gt; wybierz serwisy zawarte w solucji. Zmień przestrzeń nazw na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;NorthwindsServiceReference&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Program&lt;/em&gt; dodaj następujące klauzule &lt;em style="box-sizing: border-box; outline: none !important;"&gt;using&lt;/em&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; NorthwindsClient.NorthwindsServiceReference;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;.Diagnostics;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;.Data.Services.Client;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;.Net;&lt;/pre&gt;
&lt;ol start="5" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodaj do metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/em&gt; następujący kod:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;NorthwndEntities db =&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NorthwndEntities(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Uri(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; categories = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; c &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; db.Categories &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;select&lt;/span&gt; c;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (Categories category &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; categories)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CategoryId: {0}, CategoryName: {1}"&lt;/span&gt;, category.CategoryID, category.CategoryName));&lt;br /&gt;}&lt;/pre&gt;
&lt;ol start="6" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Ustaw aplikacje konsolową jako startową i uruchom projekt.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod odpytujący baz danych jest taki sam jak dla modelu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Entity Framework&lt;/strong&gt;. Jedyną różnicą jest utworzenie obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NorthwindsEntities&lt;/strong&gt; który tworzymy podając adres &lt;em style="box-sizing: border-box; outline: none !important;"&gt;URI&lt;/em&gt; do serwisu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Service&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Dodawanie rekordów za pomocą WCF Data Services&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod dodaje nowy rekord do tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Categories&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;NorthwndEntities db =&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NorthwndEntities(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Uri(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Create a category&lt;/span&gt;&lt;br /&gt;Categories category = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Categories() { &lt;br /&gt;    CategoryName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alcohol"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Description&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Happy Beverages"&lt;/span&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;db.AddToCategories(category);&lt;br /&gt;DataServiceResponse response = db.SaveChanges();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (response.First().StatusCode == (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;)HttpStatusCode.Created)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"New CategoryId: {0}"&lt;/span&gt;, category.CategoryID);&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Error: {0}"&lt;/span&gt;, response.First().Error.Message);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieje tutaj kilka różnic w porównaniu do dodawania rekordów za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET Entity Framework&lt;/strong&gt;. &lt;br /&gt;Po pierwsze w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NorthwindsEntities&lt;/strong&gt; została wygenerowana metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddToCategories&lt;/strong&gt;. &lt;br /&gt;Po drugie metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SaveChanges&lt;/strong&gt; zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataServiceResponse&lt;/strong&gt; który zawiera listę odpowiedzi z serwera. W powyższym przykładzie używamy właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StatusCode&lt;/strong&gt; aby sprawdzić czy rekord został dodany. &lt;br /&gt;Jeżeli uruchomimy ten kod to zwrócony zostanie nam błąd &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“An Error Occurred While Processing This Request.”&lt;/em&gt;. Dzieje się tak ponieważ nie zezwoliliśmy na tworzenie rekordów w czasie ustawiania zabezpieczeń serwisu. Aby to zmienić należy dodać następujący wpis do metody&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InitializeService&lt;/strong&gt; serwisu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;config.SetEntitySetAccessRule(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Categories"&lt;/span&gt;, EntitySetRights.AllRead &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;| &lt;/span&gt;&lt;br /&gt;    EntitySetRights.AllWrite);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;lub&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;config&lt;/span&gt;.SetEntitySetAccessRule(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Categories"&lt;/span&gt;, EntitySetRights.&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;All&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Aktualizacja rekordów za pomocą WCF Data Services&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod aktualizuje rekord z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Categories&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;NorthwndEntities db =&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NorthwndEntities(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Uri&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;Categories category = db.Categories&lt;br /&gt;    .Where(c =&amp;gt; c.CategoryName == &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alcohol"&lt;/span&gt;)&lt;br /&gt;    .FirstOrDefault();&lt;br /&gt;&lt;br /&gt;category.Description = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Happy People"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;db.UpdateObject(category);&lt;br /&gt;&lt;br /&gt;db.SaveChanges();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;UpdateObject&lt;/strong&gt; powoduje, że obiekt będzie zaktualizowany po wywołaniu metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SaveChanges&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Usuwanie rekordów za pomocą WCF Data Services&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod usuwa rekord z tabeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Categories&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;NorthwndEntities db =&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NorthwndEntities(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Uri&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;Categories category = db.Categories&lt;br /&gt;    .Where(c =&amp;gt; c.CategoryName == &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alcohol"&lt;/span&gt;)&lt;br /&gt;    .FirstOrDefault();&lt;br /&gt;&lt;br /&gt;db.DeleteObject(category);&lt;br /&gt;&lt;br /&gt;db.SaveChanges();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DeleteObject&lt;/strong&gt; usuwa rekord po wywołaniu metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SaveChanges&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Pobranie danych w formacie JSON&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Domyślnie dane są zwracane w formacie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;. Aby otrzymać dane w formacie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt; należy dołączyć nagłówek do żądania &lt;em style="box-sizing: border-box; outline: none !important;"&gt;HTTP&lt;/em&gt; o następującej treści:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;“Accep&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;t:&lt;/span&gt; application/json;odata=&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;verbose&lt;/span&gt;”&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod tworzy żądanie używając obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WebRequest&lt;/strong&gt; pobierające dane w postaci &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;HttpWebRequest req =&lt;br /&gt;    (HttpWebRequest)&lt;br /&gt;    WebRequest.Create(&lt;br /&gt;        "http://localhost/NorthwindsWCFDataService/NorthwindsService.svc/Categories(1)?$select=CategoryID,CategoryName,Description")&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;req.Accept = "application/json&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;odata=verbose";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())&lt;br /&gt;{&lt;br /&gt;    Stream s = resp.GetResponseStream()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    StreamReader readStream = new StreamReader(s)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    string jsonString = readStream.ReadToEnd()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    Debug.WriteLine(jsonString)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    resp.Close()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    readStream.Close()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;{&lt;br /&gt;    "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;d&lt;/span&gt;":&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;{&lt;br /&gt;        "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;__metadata&lt;/span&gt;":&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;{&lt;br /&gt;            "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;id&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"http://localhost:8999/NorthwindsService.svc/Categories(1)"&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;            "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;uri&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"http://localhost:8999/NorthwindsService.svc/Categories(1)"&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;            "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;type&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"NorthwindsModel.Category"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;}&lt;/span&gt;,&lt;br /&gt;        "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CategoryID&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;        "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CategoryName&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Beverages"&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;        "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Description&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Soft drinks, coffees, teas, beers, and ales"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;}&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Operacje I/O&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operacje I/O są operacjami odczytu i zapisu plików. Pliki są przechowywane w katalogach a &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; zapewnia zestaw klas służących do kopiowania, przenoszenia, usuwania i sprawdzania czy plik lub katalog istnieje. Plik jest uporządkowaną i nazwaną kolekcją bajtów które zostały zapisane do magazynu danych. Kiedy pracujemy z plikami używamy strumieni. Strumień jest obiektem w pamięci używanym do reprezentowania sekwencji bajtów w pliku. Specjalne klasy odczytujące i zapisujące służą do pracy z zakodowanymi strumieniami. Wszystkie typy służące do pracy z operacjami I/O znajdują się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.IO&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Pliki i foldery&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista klas służących do pracy z plikami i folderami:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; - klasa statyczna posiadająca metody do tworzenia, kopiowania, usuwania, przenoszenia i otwierania plików.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; - klasa instancyjna posiadająca metody do tworzenia, kopiowania, usuwania, przenoszenia i otwierania plików.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Directory&lt;/strong&gt; - klasa statyczna posiadająca metody do tworzenia, kopiowania, usuwania, przenoszenia i enumerowania przez pliki w katalogu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt; - klasa instancyjna posiadająca metody do tworzenia, kopiowania, usuwania, przenoszenia i enumerowania przez pliki w katalogu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Path&lt;/strong&gt; - klasa statyczna która dostarcza sposobów uzyskiwania informacji lub manipulowania plikami lub katalogami używając ciągu znaków.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; są podobne z wyjątkiem tego, że &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; jest klasą statyczną i nie posiada właściwości. &lt;br /&gt;Właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Directory&lt;/strong&gt; - pobiera instancję obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt; dla katalogu nadrzędnego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryName&lt;/strong&gt; - pobiera ciąg znaków dla pełnej ścieżki katalogu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exists&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli plik istnieje.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsReadOnly&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli plik jest tylko do odczytu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Length&lt;/strong&gt; - zwraca rozmiar pliku w bajtach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Name&lt;/strong&gt; - zwraca nazwę pliku.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; dziedziczy z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.IO.FileSystemInfo&lt;/strong&gt; która zawiera właściwości dla atrybutów, czasu utworzenia, pełnej nazwy, ostatniego czasu dostępu i ostatniego czasu zapisu do pliku. &lt;br /&gt;Konstruktor klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; pobiera ciąg znaków ze ścieżką i nazwą pliku, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;FileInfo &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;fileInfo&lt;/span&gt; = new FileInfo(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;@”&lt;/span&gt;c:\Samples\HelloWorld.txt”);&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;fileInfo&lt;/span&gt;.Name);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista metod klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; jest taka sama ale ich parametry różnią się od siebie. Metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; wymagają podania ścieżki pliku. &lt;br /&gt;Lista najczęściej wykorzystywanych metod klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AppendAllText&lt;/strong&gt; - tworzy obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; który może być użyty do dodania tekstu do pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CopyTo (FileInfo)&lt;/strong&gt; - kopiuje plik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Copy (File)&lt;/strong&gt; - kopiuje plik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; - tworzy plik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Decrypt&lt;/strong&gt; - odszyfrowuje plik który został zaszyfrowany przez aktualne konto.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Delete&lt;/strong&gt; - usuwa plik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Encrypt&lt;/strong&gt; - szyfruje plik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MoveTo&lt;/strong&gt; - przenosi plik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Open&lt;/strong&gt; - zwraca obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileStream&lt;/strong&gt; umożliwiający odczyt i zapis.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Replace&lt;/strong&gt; - zastępuje treść pliku treścią innego pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetAccessControl&lt;/strong&gt; - stosuje listę kontroli dostępu za pomocą obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileSecurity&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Directory&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt; są podobne do klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; z tym, że operują na folderach a nie na plikach. &lt;br /&gt;Właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exists&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli plik istnieje.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Name&lt;/strong&gt; - zwraca nazwę pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Parent&lt;/strong&gt; - zwraca obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt; dla folderu nadrzędnego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Root&lt;/strong&gt; - zwraca obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt; dla folderu głównego.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej wykorzystywanych metod klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Directory&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create (DirectoryInfo)&lt;/strong&gt; - tworzy folder.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateDirectory (Directory)&lt;/strong&gt; - tworzy folder.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Delete&lt;/strong&gt; - usuwa folder.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetAccessControl&lt;/strong&gt; - zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectorySecurity&lt;/strong&gt; zawierający listę kontroli dostępu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetDirectories&lt;/strong&gt; - zwraca tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectoryInfo&lt;/strong&gt; dla podkatalogów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFiles&lt;/strong&gt; - zwraca tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; dla plików w katalogu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFileSystemInfos&lt;/strong&gt; - zwraca tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileSystemInfo&lt;/strong&gt; dla plików i katalogów w danym katalogu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MoveTo (DirectoryInfo)&lt;/strong&gt; - przenosi folder.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MoveTo (Directory)&lt;/strong&gt; - przenosi folder.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetAccessControl&lt;/strong&gt; - stosuje listę kontroli dostępu za pomocą obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DirectorySecurity&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy przykład wyświetla listę plików i katalogów na dysku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//DirectoryInfo&lt;/span&gt;&lt;br /&gt;DirectoryInfo directoryInfo = new DirectoryInfo(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"c:\"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Directories&lt;/span&gt;&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Directories"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (FileInfo fileInfo &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; directoryInfo.GetFiles())&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(fileInfo.Name);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Files&lt;/span&gt;&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Files"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (DirectoryInfo &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;di&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; directoryInfo.GetDirectories())&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;di&lt;/span&gt;.Name);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Strumienie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Strumienie są klasami wykorzystywane do przechowywania zawartości pliku. &lt;br /&gt;Lista strumieni dostępnych w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileStream&lt;/strong&gt; - odczytują i zapisują pliki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsolatedStorageFileStream&lt;/strong&gt; - odczytują i zapisują pliki w odizolowanych magazynach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MemoryStream&lt;/strong&gt; - odczytują i zapisują w pamięci.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BufferedStream&lt;/strong&gt; - używane do przechowywania bloków bajtów w pamięci.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NetworkStream&lt;/strong&gt; - zapisują i odczytują dane w sieci używając gniazd (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;socket&lt;/em&gt;).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PipeStream&lt;/strong&gt; - zapisują i odczytują dane w sieci za pomocą kanałów zwanych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;pipe&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CryptoStream&lt;/strong&gt; - używane do łączenia danych z transformacjami kryptograficznymi.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileStream&lt;/strong&gt; może by użyta do odczytu, zapisu, otwarcia i zamknięcia plików. Poniższy przykład tworzy nowy plik, zapisuje w nim numery i zamyka plik:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;FileStream fileStream = new FileStream&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;br /&gt;    @&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"d:\Samples\Numbers.txt"&lt;/span&gt;, &lt;br /&gt;    FileMode.Truncate, &lt;br /&gt;    FileAccess.Write, &lt;br /&gt;    FileShare.None)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;for &lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;; i &amp;lt; 10; i++)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    byte[] number = new UTF8Encoding&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;)&lt;/span&gt;.GetBytes&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;i&lt;/span&gt;.ToString&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    fileStream.Write&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;number&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, number.Length)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;fileStream.Close&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konstruktor &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileStream&lt;/strong&gt; pobiera cztery parametry, ścieżkę do pliku, tryb pliku, dostęp do pliku i udostępnienie pliku. &lt;br /&gt;Enumerator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileMode&lt;/strong&gt; określa czy tworzymy, otwieramy czy czyścimy plik. &lt;br /&gt;Wartości enumeratora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileMode&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Append&lt;/strong&gt; - otwiera plik jeżeli istnieje i szuka na koncu pliku lub tworzy nowy plik jeżeli nie istnieje. Może być używany tylko z dostępem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileAccess.Write&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateNew&lt;/strong&gt; - tworzy nowy plik, jeżeli plik istnieje to zgłasza wyjątek.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Create&lt;/strong&gt; - tworzy nowy plik, jeżeli plik istnieje to go nadpisuje. Jeżeli plik istnieje ale jest ukryty to zgłoszony zostaje wyjątek.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Open&lt;/strong&gt; - otwiera plik lub zgłasza wyjątek jeżeli plik nie istnieje.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OpenOrCreate&lt;/strong&gt; - otwiera plik lub tworzy nowy jeżeli nie istnieje.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Truncate&lt;/strong&gt; - otwiera plik i czyści jego dane. Jeżeli plik nie istnieje to zgłasza wyjątek.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Enumerator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileAccess&lt;/strong&gt; określa co robimy ze strumieniem po jego utworzeniu. &lt;br /&gt;Wartości enumeratora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileAccess&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - odczyt pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; - zapis do pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadWrite&lt;/strong&gt; - odczyt i zapis do pliku.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Enumerator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileShare&lt;/strong&gt; określa typ dostępu do pliku dla innych strumieni w czasie kiedy jest on otwarty. &lt;br /&gt;Wartości enumeratora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileShare&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;None&lt;/strong&gt; - blokuje dostęp do pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - pozwala na odczyt.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; - pozwala na zapis.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadWrite&lt;/strong&gt; - pozwala na odczyt i zapis.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Delete&lt;/strong&gt; - pozwala na usuwanie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Inheritable&lt;/strong&gt; - sprawia, że uchwyt pliku jest dziedziczony przez procesy.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy tworzymy lub otwieramy plik to proces musi mieć odpowiednie uprawnienia do pliku lub katalogu aby mógł wykonać określone operacje. typy uprawnień są opisane w enumeracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Security.Permissions.FileIOPermissionAccess&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NoAccess&lt;/strong&gt; - brak dostępu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - pozwala na odczyt.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; - pozwala na zapis.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Append&lt;/strong&gt; - pozwala na dodanie danych a w tym na tworzenie nowych plików i folderów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PathDiscovery&lt;/strong&gt; - dostęp do informacji o ścieżce.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AllAccess&lt;/strong&gt; - wszystkie powyższe uprawnienia.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Klasy odczytujące i zapisujące&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy odczytujące i zapisujące (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;readers&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;writers&lt;/em&gt;) są klasami przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.IO&lt;/strong&gt; które odczytują lub zapisują zakodowane znaki ze strumieni. &lt;br /&gt;Typy klas odczytujących i zapisujących w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.IO&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryReader, BinaryWriter&lt;/strong&gt; - używany do odczytu i zapisu danych binarnych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader, StreamWriter&lt;/strong&gt; - używany do odczytu i zapisu znaków używając zakodowanej wartości do konwertowania znaków do i z bajtów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader, StringWriter&lt;/strong&gt; - używany do odczytu i zapisu znaków do i z ciągów znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextReader, TextWriter&lt;/strong&gt; - klasy abstrakcyjne dla innych klas odczytujących lub zapisujących.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt; dziedziczą z klasy abstrakcyjnej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextReader&lt;/strong&gt;. &lt;br /&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringWriter&lt;/strong&gt; dziedziczą z klasy abstrakcyjnej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriter&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; jest używana do odczytu znaków w danym kodowaniu. Domyślnym kodowaniem jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UTF-8&lt;/em&gt;. Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; można użyć do odczytania standardowego pliku tekstowego. &lt;br /&gt;Najczęściej wykorzystywane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Close&lt;/strong&gt; - zamyka czytnik strumienia i strumień.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Peek&lt;/strong&gt; - zwraca następny znak ze strumienia ale nie przechodzi do jego pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read()&lt;/strong&gt; - zwraca następny znak ze strumienia i przechodzi do jego pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read(Char[], Int32, Int32)&lt;/strong&gt; - odczytuje określoną liczbę znaków do tablicy bajtowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadBlock(Char[], Int32, Int32)&lt;/strong&gt; - odczytuje określoną liczbę znaków do tablicy bajtowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadLine&lt;/strong&gt; - odczytuje linię tekstu i zwraca ciąg znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadToEnd&lt;/strong&gt; - odczytuje wszystkie znaki od aktualnej pozycji do końca pliku i zwraca ciąg znaków.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod wyświetla treść pliku znak po znaku, linię po linii oraz całą zawartość naraz za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;StreamReader streamReader = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamReader(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"d:\Samples\Numbers.txt"&lt;/span&gt;);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Char by Char"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (!streamReader.EndOfStream)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;((&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;)streamReader.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Read&lt;/span&gt;());&lt;br /&gt;}&lt;br /&gt;streamReader.Close();&lt;br /&gt;&lt;br /&gt;streamReader = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamReader(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"d:\Samples\Numbers.txt"&lt;/span&gt;);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Line by line"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (!streamReader.EndOfStream)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(streamReader.ReadLine());&lt;br /&gt;}&lt;br /&gt;streamReader.Close();&lt;br /&gt;&lt;br /&gt;streamReader = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamReader(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"d:\Samples\Numbers.txt"&lt;/span&gt;);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Entire file"&lt;/span&gt;);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(streamReader.ReadToEnd());&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt; jest podobna do klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; z wyjątkiem tego, że zamiast odczytywać plik odczytujemy ciąg znaków. Konstruktor klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt; pobiera ciąg znaków jako parametr. &lt;br /&gt;Poniższy kod wyświetla treść pliku znak po znaku za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;StringReader stringReader = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StringReader(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello\nGoodbye"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; pos = stringReader.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Read&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (pos != -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0}"&lt;/span&gt;, (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;)pos);&lt;br /&gt;    pos = stringReader.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Read&lt;/span&gt;();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;stringReader.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; jest podobna do klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stream&lt;/strong&gt; z wyjątkiem tego, że klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; odczytuje znaki w określonym kodowaniu a klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stream&lt;/strong&gt; jest zaprojektowana do bajtowego wejścia i wyjścia. Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; można użyć do zapisu danych do pliku. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt;posiada metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteLine&lt;/strong&gt; służące do zapisu strumienia do pamięci. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AutoFlush&lt;/strong&gt; która kiedy jest ustawiona na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; to powoduje, że zapis do zasobu jest wykonywany po wywołaniu metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; a kiedy jest ustawiona na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;false&lt;/em&gt; to zapis do zasobu jest wykonywany po wywołaniu metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Flush&lt;/strong&gt; lub kiedy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; jest zamykany. &lt;br /&gt;Poniższy kod zapisuje wartości do pliku:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;StreamWriter streamWriter = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;br /&gt;    StreamWriter(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"d:\Samples\StreamWriter.txt"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;streamWriter.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ABC"&lt;/span&gt;);&lt;br /&gt;streamWriter.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;streamWriter.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;streamWriter.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parametr konstruktora przyjmuje ścieżkę do pliku. jeżeli plik istnieje to jest nadpisywany lub jest tworzony jeżeli nie istnieje. Do konstruktora można również przekazać strumień.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryWriter&lt;/strong&gt; używamy do zapisu typów prostych binarnie lub jako ciągów znaków w wybranym kodowaniu. &lt;br /&gt;Poniższy kod zapisuje dane w formacie binarnym:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;FileStream fileStream = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; FileStream(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"d:\Samples\BinaryWriter.txt"&lt;/span&gt;,&lt;br /&gt;    FileMode.Create);&lt;br /&gt;BinaryWriter binaryWriter = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; BinaryWriter(fileStream);&lt;br /&gt;&lt;br /&gt;binaryWriter.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"ABC"&lt;/span&gt;);&lt;br /&gt;binaryWriter.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;binaryWriter.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;binaryWriter.Close();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryWriter&lt;/strong&gt; potrzebuje obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stream&lt;/strong&gt; przekazanego do konstruktora.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby odczytać dane binarne należy użyć klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryReader&lt;/strong&gt;. &lt;br /&gt;Poniższy kod odczytuje plik utworzony poprzednio:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;FileStream&lt;/span&gt; fileStream = new FileStream(&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;@"d:\Samples\BinaryWriter.txt",&lt;/span&gt;&lt;br /&gt;    FileMode.Open)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;BinaryReader &lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;binaryReader &lt;/span&gt;= new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;BinaryReader(fileStream);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string &lt;/span&gt;abs = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;binaryReader.ReadString();&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;bool &lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;b &lt;/span&gt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;binaryReader.ReadBoolean();&lt;br /&gt;&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;binaryReader.ReadInt32();&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;binaryReader.Close();&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Asynchroniczne Operacje I/O&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stream&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reader&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Writer&lt;/strong&gt; zapewniają możliwość odczytu i zapisu plików asynchronicznie. &lt;br /&gt;Wykonanie asynchroniczne odbywa się z użyciem słów kluczowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy fragment kodu demonstruje asynchroniczne przeszukiwanie plików w folderze które zawierają określony ciąg znaków. Jeżeli plik zawiera szukaną frazę to jego nazwa jest wyświetlana:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;button1_Click&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Searching..."&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; outputFileName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;@"d:\Samples\FoundFiles.txt"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; SearchDirectory(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;@"d:\Samples"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"A"&lt;/span&gt;, outputFileName);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Finished"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    Process.Start(outputFileName);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt; Task &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;SearchDirectory&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; searchPath, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; searchString,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; outputFileName&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    StreamWriter streamWriter = File.CreateText(outputFileName);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;[] fileNames = Directory.GetFiles(searchPath);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; FindTextInFilesAsync(fileNames, searchString, streamWriter);&lt;br /&gt;&lt;br /&gt;    streamWriter.Close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt; Task &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;FindTextInFilesAsync&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] fileNames, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;&lt;br /&gt;    searchString, StreamWriter outputFile&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; fileName &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; fileNames)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (fileName.ToLower().EndsWith(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;".txt"&lt;/span&gt;))&lt;br /&gt;            {&lt;br /&gt;                StreamReader streamReader = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamReader(fileName);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; textOfFile = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; streamReader.ReadToEndAsync();&lt;br /&gt;                streamReader.Close();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (textOfFile.Contains(searchString))&lt;br /&gt;                {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; outputFile.WriteLineAsync(fileName);&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Serializacja&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Serializacja jest procesem transformacji obiektu do innej formy która może być przechowywana w magazynie danych lub przesyłana z jednej domeny aplikacji do innej. Proces odwrotny do serializacji to deserializacja. Obiekty można serializować do zapisu na dysku, do strumienia, do pamięci lub do przesłania przez sieć. Najbardziej popularnymi formatami serializacji są &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XML&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;JSON&lt;/strong&gt;. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; posiada klasy które wspierają serializację binarną, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt;. Można również utworzyć własny sposób serializacji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Serializacja binarna&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryFormatter&lt;/strong&gt; jest używana do binarnej serializacji obiektów. Można ją znaleźć w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Runtime.Serialization.Formatters.Binary&lt;/strong&gt;. Dwie najważniejsze metody tej klasy to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serialize&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Deserialize&lt;/strong&gt;. &lt;br /&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryFormatter&lt;/strong&gt; można użyć ze strumieniem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileStream&lt;/strong&gt; do odczytu i zapisu obiektów na dysk. Klasa która ma być serializowana musi posiadać atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[Serializable]&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu tworzy klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; i czyni ją serializowalną:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[Serializable]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; _id;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;SetId&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; id&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        _id = id;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli chcemy zapisać obiekt do magazynu danych to możemy utworzyć instancję klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryFormatter&lt;/strong&gt; i wywołać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serialize&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Person person = new Person()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;person.SetId(1)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;person.FirstName = "Joe"&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;person.LastName = "Smith"&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;IFormatter formatter = new BinaryFormatter()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Stream stream = new FileStream("Person.bin", FileMode.Create, FileAccess.Write,&lt;br /&gt;    FileShare.None)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;formatter.Serialize(stream, person)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;stream.Close()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Należy zauważyć, że nawet prywatne zmienne są zapisywane na dysk.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby odtworzyć obiekt z pliku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person.bin&lt;/em&gt; należy użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Deserialize&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;stream = new FileStream(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person.bin"&lt;/span&gt;,FileMode.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Open&lt;/span&gt;,FileAccess.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Read&lt;/span&gt;,FileShare.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Read&lt;/span&gt;);&lt;br /&gt;Person person2 = (Person)formatter.Deserialize(stream);&lt;br /&gt;stream.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Close&lt;/span&gt;();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby zapobiec serializacji pola klasy należy użyć atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[NonSerialized]&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[Serializable]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    [NonSerialized]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; _id;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;SetId&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; id&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        _id = id;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Serializacja XML&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Do serializacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt; używamy klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XmlSerializer&lt;/strong&gt; z przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Xml.Serialization&lt;/strong&gt;. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XmlSerializer&lt;/strong&gt; serializuje jedynie klasy publiczne i ich publiczne właściwości i pola oraz nie wymaga użycia atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[Serializable]&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu serializuje obiekt klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt; = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt;.SetId(1);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt;.FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Joe"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt;.LastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;XmlSerializer xmlSerializer = new XmlSerializer(typeof(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;));&lt;br /&gt;StreamWriter streamWriter = new StreamWriter(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person.xml"&lt;/span&gt;);&lt;br /&gt;xmlSerializer.Serialize(streamWriter, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;xmlns:xsi&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"http://www.w3.org/2001/XMLSchema-instance"&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;xmlns:xsd&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;"http://www.w3.org/2001/XMLSchema"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;Joe&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;Smith&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&amp;lt;/&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby pole było ignorowane podczas serializacji należy użyć atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[XmlIgnore]&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[XmlIgnore]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; FirstName;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby odtworzyć obiekt z pliku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt; należy użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Deserialize&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;XmlSerializer xmlSerializer = new XmlSerializer(typeof(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;));&lt;br /&gt;FileStream fs = new FileStream(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person.xml"&lt;/span&gt;, FileMode.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Open&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt; = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;)xmlSerializer.Deserialize(fs);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div&gt;Atrybuty używane przez &lt;strong&gt;XmlSerializer&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;XmlIgnore&lt;/strong&gt; - ignoruje pole w czasie serializacji.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;XmlAttribute&lt;/strong&gt; - mapuje pole jako atrybut.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;XmlElement&lt;/strong&gt; - mapuje pole jako węzeł.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;XmlArray&lt;/strong&gt; - używany przy serializacji kolekcji.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;XmlArrayItem&lt;/strong&gt; - używany przy serializacji kolekcji.&lt;/li&gt;
&lt;/ul&gt;
Przykład atrybutów serializacji kolekcji:
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[Serializable]
&lt;span class="hljs-keyword"&gt;public&lt;/span&gt;&lt;span class="hljs-keyword"&gt;class&lt;/span&gt;&lt;span class="hljs-title"&gt;Order&lt;/span&gt;
{
 [XmlAttribute]
 &lt;span class="hljs-keyword"&gt;public&lt;/span&gt;&lt;span class="hljs-keyword"&gt;int&lt;/span&gt; ID { &lt;span class="hljs-keyword"&gt;get&lt;/span&gt;; &lt;span class="hljs-keyword"&gt;set&lt;/span&gt;; }

 [XmlIgnore]
 &lt;span class="hljs-keyword"&gt;public&lt;/span&gt;&lt;span class="hljs-keyword"&gt;bool&lt;/span&gt; IsDirty { &lt;span class="hljs-keyword"&gt;get&lt;/span&gt;; &lt;span class="hljs-keyword"&gt;set&lt;/span&gt;; }

 [XmlArray(“Lines”)]
 [XmlArrayItem(“OrderLine”)]
 &lt;span class="hljs-keyword"&gt;public&lt;/span&gt; List&amp;lt;OrderLine&amp;gt; OrderLines { &lt;span class="hljs-keyword"&gt;get&lt;/span&gt;; &lt;span class="hljs-keyword"&gt;set&lt;/span&gt;; }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Serializacja JSON&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt; jest podobny do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt; z tym, że jest mniej obszerny. Aby serializować do postaci &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt; trzeba jawnie wstawić atrybut przed każdą właściwością która ma być serializowana. Ponadto trzeba użyć atrybutu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[DataContract]&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu pokazuje jak należy zmodyfikować klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; aby możliwa była serializacja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[DataContract]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    [DataMember]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; _id;&lt;br /&gt;    [DataMember]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName;&lt;br /&gt;    [DataMember]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;SetId&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; id&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        _id = id;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby zignorować pole należy nie umieszczać atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[DataMember]&lt;/strong&gt; przed jego deklaracją. &lt;br /&gt;Poniższy fragment kodu demonstruje serializację obiektu klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt;: &lt;br /&gt;Person person = new Person();&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;person.SetId(1)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;person.FirstName = "Joe"&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;person.LastName = "Smith"&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Stream stream = new FileStream("Person.json", FileMode.Create)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Person))&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;ser.WriteObject(stream, person)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;stream.Close()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zamiast metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serialize&lt;/strong&gt; używamy metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteObject&lt;/strong&gt;. &lt;br /&gt;Wynik działania kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;{&lt;br /&gt;    "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;FirstName&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Joe"&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;    "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LastName&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;    "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;_id&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby odczytać obiekt z postaci &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt; należy użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadObject&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt; = new &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;Stream stream = new FileStream(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Person.json"&lt;/span&gt;, FileMode.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Open&lt;/span&gt;);&lt;br /&gt;DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;person&lt;/span&gt; = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt;)ser.ReadObject(stream);&lt;br /&gt;stream.Close();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Serializacja niestandardowa&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieją dwa sposoby dostosowywania procesu serializacji. Pierwszym jest dodanie metody z odpowiednim atrybutem która będzie manipulowała danymi obiektu w czasie serializacji i deserializacji obiektu. Atrybuty których można użyć to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnDeserializedAttribute&lt;/strong&gt;,&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnDeserializingAttribute&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnSerializedAttribute&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnSerializingAttribute&lt;/strong&gt;. Dodanie tych atrybutów przed metodami powoduje ich uruchomienie w wybranej fazie procesu serializacji lub deserializacji. &lt;br /&gt;Poniższy fragment kodu dostosowuje logikę serializacji klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;OnSerializing&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;]&lt;br /&gt;internal void OnSerializingMethod&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;StreamingContext&lt;/span&gt; context)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;OnSerialized&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;]&lt;br /&gt;internal void OnSerializedMethod&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;StreamingContext&lt;/span&gt; context)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Serialize Complete"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;OnDeserializing&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;]&lt;br /&gt;internal void OnDeserializingMethod&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;StreamingContext&lt;/span&gt; context)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;OnDeserialized&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;]&lt;br /&gt;internal void OnDeserializedMethod&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;StreamingContext&lt;/span&gt; context)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    FirstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Deserialize Complete"&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Drugim sposobem dostosowania serializacji jest implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ISerializable&lt;/strong&gt;. Interfejs ten posiada jedną metodę którą trzeba zaimplementować &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetObjectData&lt;/strong&gt;. Metoda ta jest wywoływana kiedy obiekt jest serializowany. Należy zaimplementować również specjalny konstruktor który będzie wywołany podczas deserializacji. &lt;br /&gt;Poniższy fragment kodu zmienia klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; tak aby implementowała interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ISerializable&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[Serializable]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ISerializable&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; _id;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;SetId&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; id&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        _id = id;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;() &lt;/span&gt;{ }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;SerializationInfo info, StreamingContext context&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        FirstName = info.GetString(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"custom field 1"&lt;/span&gt;);&lt;br /&gt;        LastName = info.GetString(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"custom field 2"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetObjectData&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;SerializationInfo info, StreamingContext context&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        info.AddValue(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"custom field 1"&lt;/span&gt;, FirstName);&lt;br /&gt;        info.AddValue(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"custom field 2"&lt;/span&gt;, LastName);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetObjectData&lt;/strong&gt; pobiera parametr typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SerializationInfo&lt;/strong&gt; która pozwala dostosować nazwę i dane, które zostaną zapisane do strumienia. &lt;br /&gt;Wynik serializacji do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt; będzie następujący:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;{&lt;br /&gt;    "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;custom_x0020_field_x0020_1&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Joe"&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;    "&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;custom_x0020_field_x0020_2&lt;/span&gt;":&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy obiekt jest deserializowany to wywoływany jest konstruktor z parametrem typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SerializationInfo&lt;/strong&gt;. Można go użyć do odtworzenia obiektu za pomocą użytych nazw niestandardowych.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W większości przypadków zalecane jest użycie atrybutów zamiast implementowania interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ISerializable&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Tablice i kolekcje&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tablice dziedziczą z typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Array&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kolekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayList&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HashTable&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&lt;/strong&gt;, i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; znajdują się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kolekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;List&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SortedList&amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; znajdują się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Generic&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt; jest typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;first-in-first-out&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt; jest typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;last-in-first-out&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby porównywać obiekty należy zaimplementować interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary&lt;/strong&gt; przechowuje pary klucz/wartość.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kolekcje niestandardowe dziedziczą z klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CollectionBase&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;ADO.NET&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt; jest zestawem klas używanych do wykonywania komend na bazie danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Command&lt;/strong&gt; jest używany do wykonywania procedur składowanych lub instrukcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteNonQuery&lt;/strong&gt; jest używana do wykonywania instrukcji które nie zwracają wyników jak np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;INSERT&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UPDATE&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteScalar&lt;/strong&gt; jest używana do pobierania tylko jednej wartości z bazy danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DBDataReader&lt;/strong&gt; jest kursorem tylko do odczytu połączonym z bazą danych który odczytuje dane tylko w przód.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExecuteXMLReader&lt;/strong&gt; zwraca dane w postaci &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;. Aby pobrać dane w postaci &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt; z bazy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL Server&lt;/em&gt; należy użyć klauzuli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FOR XML&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; jest odłączonym od bazy zbiorem wyników i może posiadać jedną lub więcej tabel wynikowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTables&lt;/strong&gt;. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataAdapter&lt;/strong&gt; jest używana do wypełnienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataAdapter&lt;/strong&gt; może być użyta z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataSet&lt;/strong&gt; do dodawania, aktualizacji lub usuwania rekordów z bazy danych.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;ADO.NET Entity Framework&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework&lt;/strong&gt; jest narzędziem typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ORM&lt;/em&gt; które używa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ADO.NET&lt;/strong&gt; do komunikacji z baza danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework Model&lt;/strong&gt; zawiera klasy reprezentujące obiekty w bazie danych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Entity Framework Model&lt;/strong&gt; procedury składowane są zmapowane jako metody.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;WCF Data Services&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Services&lt;/strong&gt; pozwalają na dostęp do bazy danych przez sieć.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Services&lt;/strong&gt; używają protokołu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OData&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WCF Data Services&lt;/strong&gt; domyslnie zwracają dane w formacie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OData ATOM&lt;/strong&gt; ale mogą również zwracać je jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;JSON&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dane w bazie danych można odpytywać za pomocą ciągów zapytań w adresie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;URL&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;I\O&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;File&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FileInfo&lt;/strong&gt; sa używane do uzyskiwania właściwości plików oraz wykonywania operacji na plikach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obiekt strumienia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stream&lt;/strong&gt; jest używany jako reprezentacja pliku w pamięci i może być używany do zapisu i odczytu danych w pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryReader&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryWriter&lt;/strong&gt; są używane do zapisu i odczytu plików w postaci binarnej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamWriter&lt;/strong&gt; są używane do zapisu i odczytu znaków poprzez użycie kodowanej wartości do konwertowania znaków do i z postaci binarnej. Domyślnym kodowaniem jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UTF-8&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Za pomocą obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamReader&lt;/strong&gt; można odczytywać plik znak po znaku, linia po linii lub cały na raz.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringWriter&lt;/strong&gt; odczytują i zapisują ciągi znaków.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Serializacja&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Serializacja jest procesem transformacji obiektu do innej formy która może być przechowywana w magazynie danych lub przesyłana z jednej domeny aplikacji do innej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BinaryFormatter&lt;/strong&gt; służy do serializacji binarnej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XmlSerializer&lt;/strong&gt; służy do serializacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;XML&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataContractJsonSerializer&lt;/strong&gt; służy do serializacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JSON&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Serializację można modyfikować używając atrybutów lub implementując interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ISerializable&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Sat, 20 Feb 2016 19:38:49 Z</pubDate>
      <a10:updated>2016-02-20T19:38:49Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1125</guid>
      <link>http://smsoft.pl/blog/vii-uzycie-refleksji-niestandardowych-atrybutow-codedom-i-wyrazen-lambda/</link>
      <title>VII. Użycie refleksji, niestandardowych atrybutów, CodeDOM i wyrażeń Lambda</title>
      <description>&lt;p&gt;&lt;span style="color: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 32px;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Refleksja&lt;/strong&gt; - znajdywanie, wykonywanie i tworzenie typów w czasie wykonania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Atrybuty&lt;/strong&gt; - tworzenie, stosowanie i odczyt atrybutów które mogą być używane do zmiany zachowania klas.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; - tworzenie generatorów kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Wyrażenia Lambda&lt;/strong&gt; - skrócona składnia tworzenia metod bez ich deklaracji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Użycie przestrzeni nazw System.Reflection&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Refleksja odnosi się do zdolności do zbadania kodu i dynamicznego odczytu, modyfikacji lub wywołania zachowania dla assembly, modułu lub typu. Typ jest tutaj rozumiany jako klasa, interfejs, tablica, typ wartości, enumeracja, parametr lub typ generyczny. Można użyć klas w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Reflection&lt;/strong&gt; lub klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt; aby dowiedzieć się jaka jest nazwa assembly, przestrzeń nazw, właściwości, metody, klasa bazowa i wiele innych metadanych o klasie lub zmiennej.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Reflection&lt;/strong&gt; zawiera wiele klas służących do odczytu metadanych lub dynamicznego wywołania zachowania dla typu. Najczęściej wykorzystywane klasy to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt; - reprezentuje plik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DLL&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EXE&lt;/strong&gt; i zawiera właściwości dla nazwy assembly, klas, modułów i innych metadanych czasu wykonania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventInfo&lt;/strong&gt; - reprezentuje zdarzenia zdefiniowane w klasie i zawiera właściwości takie jak nazwa zdarzenia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FieldInfo&lt;/strong&gt; - reprezentuje pole zdefiniowane w klasie i zawiera właściwości takie jak to czy pole jest publiczne czy prywatne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MemberInfo&lt;/strong&gt; - abstrahuje metadane o klasie i może reprezentować zdarzenie, pole itd.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MethodInfo&lt;/strong&gt; - reprezentuje metodę zdefiniowaną w klasie i może być użyta do wywołania metody.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Module&lt;/strong&gt; - moduł jest plikiem który tworzy assembly, zwykle plik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DLL&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EXE&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParameterInfo&lt;/strong&gt; - reprezentuje deklarację parametru dla metody lub konstruktora. Pozwala na określenie typu parametru, nazwy itp.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PropertyInfo&lt;/strong&gt; - reprezentuje właściwość zdefiniowaną w klasie i zawiera właściwości takie jak nazwa i typ.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Refleksja jest bardzo potężnym narzędziem i może być użyta z niektórymi wzorcami projektowymi takimi jak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Factory&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Inversion of Control&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Klasa Assembly&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt; jest zasadniczo skompilowanym kawałkiem kodu, który jest zazwyczaj plikiem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DLL&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EXE&lt;/strong&gt;. Można użyć klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt; aby załadować assembly, odczytać metadane o assembly a nawet utworzyć instancje typów które sa zawarte w assembly. &lt;br /&gt;Lista najważniejszych właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeBase&lt;/strong&gt; - zwraca ścieżkę do assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DefinedTypes&lt;/strong&gt; - zwraca kolekcję typów zdefiniowanych w assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ExportedTypes&lt;/strong&gt; - zwraca kolekcję publicznych typów zdefiniowanych w assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FullName&lt;/strong&gt; - zwraca nazwę assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GlobalAssemblyCache&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli assembly została załadowana z &lt;em style="box-sizing: border-box; outline: none !important;"&gt;global assembly cache&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ImageRuntimeVersion&lt;/strong&gt; - zwraca wersję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt; dla assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Location&lt;/strong&gt; - zwraca ścieżkę lub lokalizację &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UNC&lt;/em&gt; dla assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Modules&lt;/strong&gt; - zwraca kolekcję zawierającą moduły w assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SecurityRuleSet&lt;/strong&gt; - zwraca wartość która wskazuje, który zestaw reguł bezpieczeństwa jest zastosowany dla assembly przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CLR&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład kodu ładującego assembly &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data&lt;/strong&gt; i wypisującego niektóre właściwości assembly:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Assembly myAssembly = Assembly.Load("System.Data, Version=&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4.0.0.0&lt;/span&gt;, Culture=neutral,&lt;br /&gt;    PublicKeyToken=b&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;77a5c56193&lt;/span&gt;4e089")&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Debug.WriteLine("CodeBase: {0}", myAssembly.CodeBase)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Debug.WriteLine("FullName: {0}", myAssembly.FullName)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Debug.WriteLine("GlobalAssemblyCache: {0}", myAssembly.GlobalAssemblyCache)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Debug.WriteLine("ImageRuntimeVersion: {0}", myAssembly.ImageRuntimeVersion)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Debug.WriteLine("Location: {0}", myAssembly.Location)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/ &lt;br /&gt;v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll &lt;br /&gt;FullName: System.Data, Version=4.0.0.0, Culture=neutral, &lt;br /&gt;PublicKeyToken=b77a5c561934e089 &lt;br /&gt;GlobalAssemblyCache: True &lt;br /&gt;ImageRuntimeVersion: v4.0.30319 &lt;br /&gt;Location: C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\ &lt;br /&gt;v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej używanych metod klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateInstance(String)&lt;/strong&gt; - tworzy instancję klasy poprzez przeszukanie assembly dla nazwy klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetCustomAttributes(Boolean)&lt;/strong&gt; - zwraca tablicę obiektów reprezentujących niestandardowe atrybuty dla tego assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetExecutingAssembly&lt;/strong&gt; - zwraca obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt; dla aktualnie wykonywanego programu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetExportedTypes&lt;/strong&gt; - zwraca klasy publiczne zawarte w assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetModule&lt;/strong&gt; - zwraca wyszczególniony moduł zawarty w assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetModules()&lt;/strong&gt; - zwraca wszystkie moduły z assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetName()&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AssemblyName&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetReferencedAssemblies&lt;/strong&gt; - zwraca tablicę obiektów&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AssemblyName&lt;/strong&gt; reprezentującą wszystkie assembly do których odwołuje się to assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetTypes&lt;/strong&gt; - zwraca tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Type&lt;/strong&gt; zdefiniowanych w tym assembly.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Load(String)&lt;/strong&gt; - ładuje assembly wg długiej nazwy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LoadFile(String)&lt;/strong&gt; - ładuje zawartość pliku assembly wg ścieżki pliku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LoadFrom(String)&lt;/strong&gt; - ładuje assembly wg nazwy lub ścieżki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReflectionOnlyLoad(String)&lt;/strong&gt; - ładuje assembly, ale można wykonać na jej typach tylko refleksję.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;UnsafeLoadFrom&lt;/strong&gt; - ładuje assembly pomijając pewne kroki bezpieczeństwa.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda statyczna &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetExecutingAssembly&lt;/strong&gt; pozwalająca na pobranie referencji do aktualnie wykonywanego kodu. Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetExportedTypes&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetTypes&lt;/strong&gt; są używane do pobierania referencji do typów zdefiniowanych w assembly. &lt;br /&gt;Poniższy fragment kodu wyświetla wszystkie typy zdefiniowane w aktualnie wykonywanym assembly:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Assembly&lt;/span&gt; myAssembly = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Assembly&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetExecutingAssembly&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Type&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; myAssemblysTypes = myAssembly.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetTypes&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Type&lt;/span&gt; myType &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myAssemblysTypes)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Debug&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Format&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"myType Name: {0}"&lt;/span&gt;, myType.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt;));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Modules&lt;/strong&gt; lub metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetLoadedModules&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetModules&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetModule&lt;/strong&gt; zwracają listę modułów ()lub wybrany moduł) zdefiniowanych w assembly. Moduł jest plikiem który wchodzi w skład assembly. Jest to zwykle jeden plik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DLL&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EXE&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu wyświetla wszystkie moduły zdefiniowane w assembly &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Assembly&lt;/span&gt; myAssembly = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Assembly&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Load&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"System.Data, Version=4.0.0.0, Culture=neutral,&lt;br /&gt;    PublicKeyToken=b77a5c561934e089"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Module&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; myAssemblysModules = myAssembly.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetModules&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Module&lt;/span&gt; myModule &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; myAssemblysModules)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Debug&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Format&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Module Name: {0}"&lt;/span&gt;, myModule.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt;));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania fragmentu kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Module Name: System.Data.dll&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poprzedni fragment kodu użył metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Load&lt;/strong&gt; aby załadować assembly &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data&lt;/strong&gt; do pamięci. Ponieważ assembly została załadowana używając metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Load&lt;/strong&gt; to można wykonywać kod należący do assembly. Jeżeli nie potrzebujemy wykonywać kodu to możemy użyć metody&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReflectionOnlyLoad&lt;/strong&gt;. &lt;br /&gt;Assembly możemy także załadować za pomocą metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LoadFrom&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LoadFile&lt;/strong&gt; które pobierają ścieżkę jako parametr. Różnica pomiędzy tymi metodami polega na różnych typach kontekstów w jakich refleksja wyszukuje assembly. Assembly może być w jednym z trzech kontekstów lub w żadnym z nich:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;load context&lt;/strong&gt; - zawiera assembly odnalezione poprzez wykrywanie w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;GAC&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;host assembly store&lt;/em&gt;, folderze assembly lub w folderze prywatnym bin.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;load-from context&lt;/strong&gt; - zawiera assembly zlokalizowane w ścieżce podanej jako parametr.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;reflection-only context&lt;/strong&gt; - zawiera assembly załadowane przez metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReflectionOnlyLoad&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReflectionOnlyLoadFrom&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Rekomendowaną metodą jest użycie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Load&lt;/strong&gt;. Użycie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LoadFrom&lt;/strong&gt; wymaga praw dostępu oraz mogą w nim wystąpić konflikty nazw i identyfikatorów. Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LoadFile&lt;/strong&gt; możemy użyć jeżeli istnieją dwie assembly z tym samym identyfikatorem w różnych folderach na komputerze.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy mamy już załadowane assembly to możemy utworzyć instancje klas zdefiniowanych w tym assembly. Aby utworzyć instancję klasy używamy metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateInstance&lt;/strong&gt;. &lt;br /&gt;Poniższy fragment kodu tworzy instancję klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DataTable&lt;/strong&gt; i wypisuje liczbę wierszy w tabeli:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Assembly myAssembly = Assembly.Load("System.Data, Version=&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4.0.0.0&lt;/span&gt;, Culture=neutral,&lt;br /&gt;    PublicKeyToken=b&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;77a5c56193&lt;/span&gt;4e089")&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;DataTable dt = (DataTable)myAssembly.CreateInstance("System.Data.DataTable")&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Debug.Print("Number of rows: {0}", dt.Rows.Count)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli jako parametr metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CreateInstance&lt;/strong&gt; podamy nieistniejącą nazwę klasy to zwrócona zostanie wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt; i nie zostanie zgłoszony żaden wyjątek.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetReferencesAssemblies&lt;/strong&gt; jest używana do odkrywania referencji w assembly. Może to być przydatne podczas rozwiązywania problemów wdrażania. &lt;br /&gt;Poniższy kod wypisuje wszystkie referencje dla assembly &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Assembly myAssembly = Assembly.Load("System.Data, Version=&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4.0.0.0&lt;/span&gt;, Culture=neutral,&lt;br /&gt;    PublicKeyToken=b&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;77a5c56193&lt;/span&gt;4e089")&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;AssemblyName[] referencedAssemblyNames = myAssembly.GetReferencedAssemblies()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;foreach (AssemblyName assemblyName in referencedAssemblyNames)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine("Assembly Name: {0}", assemblyName.Name)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    Debug.WriteLine("Assembly Version: {0}", assemblyName.Version)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Assembly Name: mscorlib &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System.Xml &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System.Configuration &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System.Transactions &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System.Numerics &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System.EnterpriseServices &lt;br /&gt;Assembly Version: 4.0.0.0 &lt;br /&gt;Assembly Name: System.Core &lt;br /&gt;Assembly Version: 4.0.0.0&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Klasa System.Type&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt; reprezentuje klasę, interfejs, tablicę, typ wartości, enumerację, parametr i typ generyczny. Najczęściej jest używana do pobrania informacji o klasie zawartej w assembly. Możesz uzyskać odwołanie do typu na dwa sposoby. &lt;br /&gt;Można użyć słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;typeof()&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;System.Type myType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można również użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetType()&lt;/strong&gt; na instancji typu, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; myIntVariable = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;System.Type myType = myIntVariable.GetType();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy posiadamy referencję do typu to możemy zbadać jego właściwości. Lista najczęściej używanych właściwości dla klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly&lt;/strong&gt; w którym typ jest zadeklarowany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AssemblyQualifiedName&lt;/strong&gt; - zwraca ciąg znaków, który jest kompletną nazwą tego typu, i który zawiera nazwę assembly, z którego typ został załadowany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BaseType&lt;/strong&gt; - zwraca typ z którego dany typ dziedziczy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FullName&lt;/strong&gt; - zwraca ciąg znaków, który jest kompletną nazwą tego typu z przestrzenią nazw.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsAbstract&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest abstrakcyjny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsArry&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest tablicą.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsClass&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest klasą a nie interfejsem ani typem wartości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsEnum&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest enumeracją.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsInterface&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest interfejsem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNotPublic&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ nie jest zadeklarowany jako publiczny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsPublic&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest zadeklarowany jako publiczny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsSerializable&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest serializowany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsValueType&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli typ jest typem wartości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Name&lt;/strong&gt; - zwraca nazwę typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Namespace&lt;/strong&gt; - zwraca przestrzeń nazw typu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład wyświetlający niektóre właściwości typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; myIntVariable = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;System.Type myType = myIntVariable.GetType();&lt;br /&gt;&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"AssmeblyQualifiedName: {0}"&lt;/span&gt;, myType.AssemblyQualifiedName);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FullName: {0}"&lt;/span&gt;, myType.FullName);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"IsValueType: {0}"&lt;/span&gt;, myType.IsValueType);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Name: {0}"&lt;/span&gt;, myType.Name);&lt;br /&gt;Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Namespace: {0}"&lt;/span&gt;, myType.Namespace);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;AssmeblyQualifiedName: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, &lt;br /&gt;PublicKeyToken=b77a5c561934e089 &lt;br /&gt;FullName: System.Int32 &lt;br /&gt;IsValueType: True &lt;br /&gt;Name: Int32 &lt;br /&gt;Namespace: System&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt; posiada również metody których można użyć do pobrania metadanych typu. &lt;br /&gt;Lista najczęściej wykorzystywanych metod klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetArrayRank&lt;/strong&gt; - jeżeli typ jest tablicą, to metoda zwraca liczbę wymiarów w tablicy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetConstructor(Type[])&lt;/strong&gt; - szuka publicznych wystąpień konstruktora którego parametry pasują do typów określonych w tablicy i zwraca obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConstructorInfo&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetConstructors()&lt;/strong&gt; - zwraca tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConstructorInfo&lt;/strong&gt; dla wszystkich publicznych konstruktorów zdefiniowanych dla danego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumName&lt;/strong&gt; - jeżeli typ jest enumeracją to metoda zwraca nazwę elementu który posiada określoną wartość.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumNames&lt;/strong&gt; - jeżeli typ jest enumeracją to metoda zwraca wszystkie nazwy członków enumeracji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumValues&lt;/strong&gt; - jeżeli typ jest enumeracją to metoda zwraca tablicę wartości enumeracji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetField(String)&lt;/strong&gt; - szuka publicznego pola o określonej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFields()&lt;/strong&gt; - zwraca wszystkie publiczne pola.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetInterface(String)&lt;/strong&gt; - zwraca interfejs o określonej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMember(String)&lt;/strong&gt; - zwraca publiczny element o określonej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMembers&lt;/strong&gt; - zwraca wszystkie publiczne element typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMethod(String)&lt;/strong&gt; - zwraca publiczną metodę o określonej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMethods()&lt;/strong&gt; - zwraca wszystkie metody publiczne typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetProperty(String)&lt;/strong&gt; - zwraca publiczną właściwość o określonej nazwie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetProperties()&lt;/strong&gt; - zwraca wszystkie publiczne właściwości typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetTypeArray&lt;/strong&gt; - zwraca wszystkie typy obiektów w wybranej tablicy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvokeMember(String, BindingFlags, Binder, Object, Object[])&lt;/strong&gt; - wykonuje metodę używając określonych powiązan i dopasowując listę argumentów.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GetArrayRank&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli typ jest tablicą, to metoda zwraca liczbę wymiarów w tablicy. Poniższy kod tworzy trzy-wymiarową tablicę i wyświetla liczbę wymiarów tablicy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;int[,,] myIntArray = new int[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;,&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;,&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;]&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Type myIntArrayType = myIntArray.GetType()&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;Debug.Print(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Array Rank: {0}"&lt;/span&gt;, myIntArrayType.GetArrayRank())&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;3&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GetConstructors&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda zwraca tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConstructorInfo&lt;/strong&gt; dla wszystkich publicznych konstruktorów zdefiniowanych dla danego typu. Poniższy kod wyświetla konstruktory publiczne dla klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.DataTable&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;DataTable myDataTable = new DataTable();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Type&lt;/span&gt; myDataTableType = myDataTable.GetType();&lt;br /&gt;ConstructorInfo[] myDataTableConstructors = myDataTableType.GetConstructors();&lt;br /&gt;&lt;br /&gt;for(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt;= myDataTableConstructors.Length - &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; i++)&lt;br /&gt;{&lt;br /&gt;    ConstructorInfo constructorInfo = myDataTableConstructors[i];&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Print&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"\nConstructor #{0}"&lt;/span&gt;, i + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    ParameterInfo[] parameters = constructorInfo.GetParameters();&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Print&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Number Of Parameters: {0}"&lt;/span&gt;, parameters.Length);&lt;br /&gt;&lt;br /&gt;    foreach (ParameterInfo &lt;span style="box-sizing: border-box; outline: none !important;"&gt;parameter&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;in&lt;/span&gt; parameters)&lt;br /&gt;    {&lt;br /&gt;        Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Print&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Parameter Name: {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;parameter&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Name&lt;/span&gt;);&lt;br /&gt;        Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Print&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Parameter Type: {0}"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;parameter&lt;/span&gt;.ParameterType.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Name&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Constructor #1 &lt;br /&gt;Number Of Parameters: 0 &lt;br /&gt;Constructor #2 &lt;br /&gt;Number Of Parameters: 1 &lt;br /&gt;Parameter Name: tableName &lt;br /&gt;Parameter Type: String &lt;br /&gt;Constructor #3 &lt;br /&gt;Number Of Parameters: 2 &lt;br /&gt;Parameter Name: tableName &lt;br /&gt;Parameter Type: String &lt;br /&gt;Parameter Name: tableNamespace &lt;br /&gt;Parameter Type: String&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GetEnumName, GetEnumNames i GetEnumValues&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli typ jest enumeracją to metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnum…&lt;/strong&gt; pozwalają na pobranie wszystkich nazw i wartości enumeracji. &lt;br /&gt;Przykładowa enumeracja:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;enum&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e; font-style: italic;"&gt;MyCustomEnum&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Red&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;White&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Blue&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod wyświetlający wszystkie nazwy enumeracji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Type myCustomEnumType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(MyCustomEnum);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;[] enumNames = myCustomEnumType.GetEnumNames();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; enumName &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; enumNames)&lt;br /&gt;{&lt;br /&gt;    Debug.Print(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Name: {0}"&lt;/span&gt;, enumName));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Name: Red &lt;br /&gt;Name: White &lt;br /&gt;Name: Blue&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wartości enumeracji można pobrać za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumValues&lt;/strong&gt;. Poniższa metoda wyświetla wszystkie wartości enumeracji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Type&lt;/span&gt; myCustomEnumType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(MyCustomEnum);&lt;br /&gt;Array enumValues = myCustomEnumType.GetEnumValues();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (object enumValue &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; enumValues)&lt;br /&gt;{&lt;br /&gt;    Debug.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Print&lt;/span&gt;(string.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Format&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Enum Value: {0}"&lt;/span&gt;, enumValue.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ToString&lt;/span&gt;()));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Enum Value: Red &lt;br /&gt;Enum Value: White &lt;br /&gt;Enum Value: Blue&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zauważmy, że wartości są takie same jak nazwy.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można również użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumName&lt;/strong&gt; aby pobrać nazwę. Poniższy kod wyświetla wszystkich członków używając wartości enumeracji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Type myCustomEnumType = typeof&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;MyCustomEnum&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;for &lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;; i &amp;lt;= 3; i++)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    string enumName = myCustomEnumType.GetEnumName&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;i&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    Debug.Print&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0}: {1}"&lt;/span&gt;, enumName, i)&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Red: 1 &lt;br /&gt;White: 2 &lt;br /&gt;Blue: 3&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GetField i GetFields&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pole jest zmienną zdefiniowaną w klasie lub strukturze. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetField&lt;/strong&gt; jest używana do pobrania obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FieldInfo&lt;/strong&gt; dla pola. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFields&lt;/strong&gt; pobiera tablicę obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FieldInfo&lt;/strong&gt;. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFields&lt;/strong&gt; może również zwrócić pola z odziedziczonych klas. Kiedy ją wywołujemy to wstawiamy enumerację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BindingFlags&lt;/strong&gt; aby wybrać zakres pól które chcemy pobrać. &lt;br /&gt;Poniższa klasa zawiera pięć pól z różnych zakresów:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ReflectionExample&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; _privateField = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; _publicField = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Goodbye"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; _internalfield = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hola"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;protected&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; _protectedField = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Adios"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; _staticField = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bonjour"&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Możemy użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFields&lt;/strong&gt; aby pobrać wartości tych zmiennych w zależności od zakresu, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ReflectionExample reflectionExample = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ReflectionExample();&lt;br /&gt;Type reflectionExampleType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(ReflectionExample);&lt;br /&gt;&lt;br /&gt;FieldInfo[] fields = reflectionExampleType.GetFields(BindingFlags.Public |&lt;br /&gt;    BindingFlags.Instance |&lt;br /&gt;    BindingFlags.Static |&lt;br /&gt;    BindingFlags.NonPublic |&lt;br /&gt;    BindingFlags.FlattenHierarchy);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (FieldInfo field &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; fields)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; fieldValue = field.GetValue(reflectionExample);&lt;br /&gt;&lt;br /&gt;    Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Field Name: {0}, Value: {1}"&lt;/span&gt;, field.Name,&lt;br /&gt;        fieldValue.ToString()));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Field Name: _privateField, Value: Hello &lt;br /&gt;Field Name: _publicField, Value: Goodbye &lt;br /&gt;Field Name: _internalfield, Value: Hola &lt;br /&gt;Field Name: _protectedField, Value: Adios &lt;br /&gt;Field Name: _staticField, Value: Bonjour&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wywołując metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFields&lt;/strong&gt;możemy użyć operatora bitowego aby wybrać więcej niż jedną wartość enumeracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BindingFlags&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dzięki refleksji można odczytać także zmienne prywatne więc trzeba mieć na uwadze co zapisujemy w tych zmiennych.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FieldInfo&lt;/strong&gt; posiada także metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetValue&lt;/strong&gt; która pozwala zmienić wartość zmiennej, nawet jeżeli jest prywatna lub chroniona. &lt;br /&gt;Przykładowo dodajmy do klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ReflectionExample&lt;/em&gt; właściwość:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; PrivateField&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; privateField; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod zmienia wartość zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;privateField&lt;/em&gt; i ją wyświetla:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ReflectionExample reflectionExample = new ReflectionExample();&lt;br /&gt;Type reflectionExampleType = typeof(ReflectionExample);&lt;br /&gt;&lt;br /&gt;reflectionExampleType.GetField(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"privateField"&lt;/span&gt;, BindingFlags.NonPublic |&lt;br /&gt;    BindingFlags.Instance).&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;SetValue&lt;/span&gt;(reflectionExample, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"My New Value"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Debug&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Print&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Private Field Value: {0}"&lt;/span&gt;,&lt;br /&gt;    reflectionExample.PrivateField);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Private Field Value: My New Value&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GetProperty i GetProperties&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetProperty&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetProperties&lt;/strong&gt; są podobne do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetField&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetFields&lt;/strong&gt; ponieważ pozwalają na pobranie właściwości, pobranie ich wartości i ustawienie ich wartości. Metody zwracają obiekty klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PropertyInfo&lt;/strong&gt; zamiast &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FieldInfo&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;GetMethod i GetMethods&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMethod&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMethods&lt;/strong&gt; pozwalają na pobranie informacji o metodach danego typu. Po pobraniu referencji do metody możemy ją wykonać za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Invoke&lt;/strong&gt; obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MethodInfo&lt;/strong&gt;. Wybraną metodę można również wykonać za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvokeMember&lt;/strong&gt; klasy&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt;. &lt;br /&gt;Dodajmy poniższą metodę do klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ReflectionExample&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Multiply&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; x, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; y)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x * y;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod wykonuje metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Multiply&lt;/em&gt; i wyświetla jej wynik:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ReflectionExample reflectionExample = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ReflectionExample();&lt;br /&gt;Type reflectionExampleType = typeof(ReflectionExample);&lt;br /&gt;&lt;br /&gt;MethodInfo methodInfo = reflectionExampleType.GetMethod(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Multiply"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; returnValue = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;)methodInfo.Invoke(reflectionExample,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; object[] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;Debug.Print(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Return Value: {0}"&lt;/span&gt;, returnValue);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parametry metody wstawiamy używając tablicy obiektów jako drugiego parametru metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Invoke&lt;/strong&gt;. &lt;br /&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Return Value: 20&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Używając metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvokeMember&lt;/strong&gt; składnia jest następująca:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;ReflectionExample reflectionExample = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ReflectionExample();&lt;br /&gt;Type reflectionExampleType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(ReflectionExample);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; returnValue = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;)reflectionExampleType.InvokeMember(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Multiply"&lt;/span&gt;,&lt;br /&gt;    BindingFlags.InvokeMethod,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;,&lt;br /&gt;    reflectionExample,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt;[] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt; });&lt;br /&gt;&lt;br /&gt;Debug.Print(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Return Value: {0}"&lt;/span&gt;, returnValue));&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Drugim parametrem jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BindingFlags.InvokeMethod&lt;/strong&gt;, która wywołuje metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvokeMember&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Odczyt i tworzenie atrybutów niestandardowych&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Atrybuty pozwalają definiować metadane dla klas, właściwości lub metod. Klasa, właściwość lub metoda są określane jako cel atrybutu. Refleksja może być użyta do odczytu tych atrybutów dynamicznie i zmiany zachowania celu. Atrybuty są zawarte w nawiasy kwadratowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;“[ ]”&lt;/strong&gt; powyżej celu i mogą być układane jeden po drugim gdy potrzebnych jest wiele atrybutów do definiowania celu. Przykładowo jeżeli chcemy aby klasa była serializowalna to musimy dodać atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[Serializable()]&lt;/strong&gt; do definicji klasy, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[Serializable()]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;MyClass&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//…&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serializable&lt;/strong&gt; jest klasą zdefiniowaną w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework’u&lt;/em&gt; która dziedziczy z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Attribute&lt;/strong&gt;. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Attribute&lt;/strong&gt; jest klasą abstrakcyjną która jest klasą bazową dla wszystkich atrybutów niestandardowych.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Odczyt atrybutów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przestrzen nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Reflection&lt;/strong&gt; posiada wiele klas pozwalających na odczyt metadanych klas wewnątrz assembly. Assembly posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetCustomAttributes&lt;/strong&gt; która pozwala na odczyt wszystkich klas atrybutów niestandardowych zdefiniowanych w assembly lub odfiltrowanie konkretnego typu atrybutu. &lt;br /&gt;Poniższy kod iteruje przez wszystkie assembly do których odnosi się aktualna assembly i wyświetla nazwy klas niestandardowych atrybutów:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Assembly assembly = Assembly.GetExecutingAssembly();&lt;br /&gt;AssemblyName[] assemblyNames = assembly.GetReferencedAssemblies();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (AssemblyName assemblyName &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; assemblyNames)&lt;br /&gt;{&lt;br /&gt;    Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"\nAssembly Name: {0}"&lt;/span&gt;, assemblyName.FullName);&lt;br /&gt;&lt;br /&gt;    Assembly referencedAssembly = Assembly.Load(assemblyName.FullName);&lt;br /&gt;&lt;br /&gt;    object[] attributes = referencedAssembly.GetCustomAttributes(false);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (object attribute &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; attributes)&lt;br /&gt;    {&lt;br /&gt;        Debug.WriteLine(\nAttribute Name: {0}",&lt;br /&gt;            attribute.GetType().Name);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Get the properties of this attribute&lt;/span&gt;&lt;br /&gt;        PropertyInfo[] properties = attribute.GetType().GetProperties();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (PropertyInfo property &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; properties)&lt;br /&gt;        {&lt;br /&gt;            Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0} : {1}"&lt;/span&gt;, property.Name,&lt;br /&gt;                property.GetValue(attribute));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aktualnie wykonywane assembly posiada referencje do: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;mscorlib&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System&lt;/strong&gt;. Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Assembly Name: mscorlib, Version=4.0.0.0, Culture=neutral, &lt;br /&gt;PublicKeyToken=b77a5c561934e089 &lt;br /&gt;Attribute Name: StringFreezingAttribute &lt;br /&gt;TypeId : System.Runtime.CompilerServices.StringFreezingAttribute &lt;br /&gt;… &lt;br /&gt;Assembly Name: System, Version=4.0.0.0, Culture=neutral, &lt;br /&gt;PublicKeyToken=b77a5c561934e089 &lt;br /&gt;Attribute Name: ComVisibleAttribute &lt;br /&gt;Value : False &lt;br /&gt;TypeId : System.Runtime.InteropServices.ComVisibleAttribute&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Tworzenie atrybutów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby utworzyć własny atrybut niestandardowy należy utworzyć klasę dziedziczącą z klasy abstrakcyjnej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Attribute&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;MyCustomAttribute&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important;"&gt;System.Attribute&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Nazywając klasę atrybutu należy dodać do nazwy sufiks &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Attribute&lt;/strong&gt;. Kiedy korzystamy z atrybutów możemy odwoływać się do nich pomijając sufiks.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Po zadeklarowaniu klasy można dodać do niej właściwości i enumeracje tak samo jak do każdej innej klasy. &lt;br /&gt;Przykładowo dodajmy enumerację i trzy właściwości:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;MyCustomAttribute&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;System&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Attribute&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;enum&lt;/span&gt; MyCustomAttributeEnum&lt;br /&gt;    {&lt;br /&gt;        Red,&lt;br /&gt;        White,&lt;br /&gt;        Blue&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;bool&lt;/span&gt; Property1 { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Property2 { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; MyCustomAttributeEnum Property3 { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolejnym krokiem jest zdefiniowanie zakresu atrybutu. Przykładowo ograniczymy zakres atrybutu do klas i struktur. Aby tego dokonać używamy atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.AttributeUsage&lt;/strong&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;[System.AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;MyCustomAttribute&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important;"&gt;System.Attribute&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//…&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Teraz możemy użyć tego atrybutu definiując klasę, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;MyCustom&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Property1&lt;/span&gt; = true, Property2 = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;, Property3 =&lt;br /&gt;MyCustomAttribute.MyCustomAttributeEnum.Red)&lt;/span&gt;]&lt;br /&gt;class MyTestClass&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zauważmy, że użyliśmy nazwy atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MyCustom&lt;/strong&gt; a nie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MyCustomAttribute&lt;/strong&gt;. &lt;br /&gt;Aby ustawić wartości właściwości wstawiliśmy ich wartości jako parametry nazwane. Można również dodać konstruktor do klasy atrybutu i w nim ustawić wartości.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Teraz gdy mamy klasę z atrybutami to możemy odczytać wartośi właściwości atrybutów za pomocą refleksji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Type&lt;/span&gt; myTestClassType = typeof(MyTestClass);&lt;br /&gt;MyCustomAttribute &lt;span style="box-sizing: border-box; outline: none !important;"&gt;attribute&lt;/span&gt; =&lt;br /&gt;    (MyCustomAttribute)myTestClassType.GetCustomAttribute&lt;br /&gt;        (&lt;br /&gt;            typeof(MyCustomAttribute),&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;false&lt;/span&gt;&lt;br /&gt;        );&lt;br /&gt;&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Property1: {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;attribute&lt;/span&gt;.Property1);&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Property2: {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;attribute&lt;/span&gt;.Property2);&lt;br /&gt;Debug.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Property3: {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;attribute&lt;/span&gt;.Property3);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Property1: True &lt;br /&gt;Property2: Hello World &lt;br /&gt;Property3: Red&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Generowanie kodu za pomocą CodeDOM&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;The Code Document Object Model&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; jest zestawem klas w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; który umożliwia tworzenie generatorów kodu. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; zawiera klasy reprezentujące właściwości, metody, klasy, logikę, parametry i inne typy kodu.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można użyć klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; do wygenerowania kodu w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C#&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;VB.NET&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;JScript&lt;/strong&gt;. Kod wygenerowany przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; jest bardzo dobry do automatyzacji powtarzalnych zadań lub egzekwowania wzorców w projekcie.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W tej sekcji zademonstrujemy jak utworzyć klasę która posiada pola, właściwości i metody, używając &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt;. &lt;br /&gt;Typowa struktura klasy w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; posiada następujące elementy:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Plik tekstowy w którym znajduje się kod klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zestaw wyrażeń &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Deklarację przestrzeni nazw.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Deklarację nazwy klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zestaw pól, właściwości i metod. Metody mogą posiadać logikę z pętlami, wyrażeniami itp.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; posiada klasy które umożliwiają utworzenie struktóry nazywanej grafem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM Graph&lt;/strong&gt;, który modeluje te elementy.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista najczęściej używanych klas przestrzeni &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeArgumentReferenceExpression&lt;/strong&gt; - reprezentuje referencję do wartości argumentu wstawianego do metody.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeAssignStatement&lt;/strong&gt; - instrukcja przypisania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeBinaryOperatorExpression&lt;/strong&gt; - wyrażenie zawierające operację binarną.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeCastExpression&lt;/strong&gt; - wyrażenie rzutowania typów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeComment&lt;/strong&gt; - komentarz.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeCompileUnit&lt;/strong&gt; - kontener dla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt;, zawierający deklaracje, przestrzeń nazw, klasy i komponenty klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeConditionStatement&lt;/strong&gt; - instrukcja warunkowa np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;if&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeConstructor&lt;/strong&gt; - konstruktor.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeFieldReferenceExpression&lt;/strong&gt; - referencja do pola.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeIterationStatement&lt;/strong&gt; - pętla np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;for&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberEvent&lt;/strong&gt; - deklaracja zdarzenia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberField&lt;/strong&gt; - deklaracja pola.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberMethod&lt;/strong&gt; - deklaracja metody.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberProperty&lt;/strong&gt; - deklaracja waściwości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMethodInvokeExpression&lt;/strong&gt; - wyrażenie wywołujące metodę.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMethodReturnStatement&lt;/strong&gt; - instrukcja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;return&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeNamespace&lt;/strong&gt; - deklaracja przestrzeni nazw.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeNamespaceImport&lt;/strong&gt; - dyrektywa importu przestrzeni nazw.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeObjectCreateExpression&lt;/strong&gt; - wyrażenie tworzące nową instancję typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeParameterDeclarationExpression&lt;/strong&gt; - deklaracja parametru dla metody, właściwości lub konstruktora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodePropertyReferenceExpression&lt;/strong&gt; - referencja do wartości właściwości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodePropertySetValueReferenceExpression&lt;/strong&gt; - argument wartości dla metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;set&lt;/em&gt; właściwości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeRegionDirective&lt;/strong&gt; - nazwa i tryb regionu kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeSnippetCompileUnit&lt;/strong&gt; - reprezentuje tekstowy fragment kodu który może być skompilowany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeSnippetStatement&lt;/strong&gt; - reprezentuje tekstowy fragment kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeThisReferenceExpression&lt;/strong&gt; - referencja do instancji klasy lokalnej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeThrowExceptionStatement&lt;/strong&gt; - wyrażenie wyrzucania wyjątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeTryCatchFinallyStatement&lt;/strong&gt; - blok &lt;em style="box-sizing: border-box; outline: none !important;"&gt;try-catch-finally&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeTypeConstructor&lt;/strong&gt; - statyczny konstruktor klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeTypeDeclaration&lt;/strong&gt; - deklaracja klasy, struktury, interfejsu lub enumeracji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeTypeDelegate&lt;/strong&gt; - deklaracja delegaty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeVariableDeclarationStatement&lt;/strong&gt; - deklaracja zmiennej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeVariableReferenceExpression&lt;/strong&gt; - referencja do zmiennej lokalnej.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; posiada klasę dla każdego typu wyrażenia które można utworzyć w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt;. &lt;br /&gt;Kod klasy który wygenerujemy za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Linq;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Threading.Tasks;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;namespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Reflection&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Calculator&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; X { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; Y { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Divide&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Y == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.X / &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Y;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Exponent&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; power&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; Math.Pow(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.X, power);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jest to prosta klasa nazwana &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Calculator&lt;/strong&gt; znajdująca się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reflection&lt;/strong&gt;, zawierająca dwa pola, dwie właściwości i dwie metody. poniższe sekcje zademonstrują jak wygenerować taką klasę dynamicznie za pomocą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeCompileUnit&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeCompileUnit&lt;/strong&gt; jest kontenerem dla wszystkich obiektów które chcemy wygenerować. Mozna myśleć o niej jak o pliku który ma zawierać cały wygenerowany kod. &lt;br /&gt;Poniższy kod służy do utworzenia instancji tej klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeCompileUnit codeCompileUnit = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeCompileUnit();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeNamespace i CodeNamespaceImport&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeNamespace&lt;/strong&gt; jest używana do deklarowania przestrzenii nazw. Konstruktor tej klasy pobiera nazwę przestrzeni nazw jako parametr:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeNamespace codeNamespace = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeNamespace(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Reflection"&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeNamespaceImport&lt;/strong&gt; dodaje instrukcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;codeNamespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Imports&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CodeNamespaceImport&lt;/span&gt;("&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;"));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;codeNamespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Imports&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CodeNamespaceImport&lt;/span&gt;("&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Collections&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Generic&lt;/span&gt;"));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;codeNamespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Imports&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CodeNamespaceImport&lt;/span&gt;("&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Linq&lt;/span&gt;"));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;codeNamespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Imports&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CodeNamespaceImport&lt;/span&gt;("&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Text&lt;/span&gt;"));&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;codeNamespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Imports&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CodeNamespaceImport&lt;/span&gt;("&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;System&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Threading&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Tasks&lt;/span&gt;"));&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeTypeDeclaration&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeTypeDeclaration&lt;/strong&gt; służy do deklaracji klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeTypeDeclaration targetClass = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeDeclaration(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Calculator"&lt;/span&gt;);&lt;br /&gt;targetClass.IsClass = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;targetClass.TypeAttributes = TypeAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Public&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Add the class to the namespace.&lt;/span&gt;&lt;br /&gt;codeNamespace.Types.Add(targetClass);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ustawienie wartości właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsClass&lt;/strong&gt; na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; mówi &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework’owi&lt;/em&gt;, że ma wygenerować deklarację klasy. Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TypeAttributes&lt;/strong&gt; pozwala deklarować atrybuty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;public&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;private&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;static&lt;/strong&gt;. Można je kombinować za pomocą operatora bitowego (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;|&lt;/strong&gt;). Po zadeklarowaniu klasy należy ją dodać do kolekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Types&lt;/strong&gt; przestrzeni nazw.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeMemberField&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberField&lt;/strong&gt; deklarujemy pola klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeMemberField xField = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMemberField();&lt;br /&gt;xField.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"x"&lt;/span&gt;;&lt;br /&gt;xField.Type = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReference(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;));&lt;br /&gt;targetClass.Members.Add(xField);&lt;br /&gt;&lt;br /&gt;CodeMemberField yField = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMemberField();&lt;br /&gt;yField.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"y"&lt;/span&gt;;&lt;br /&gt;yField.Type = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReference(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;));&lt;br /&gt;targetClass.Members.Add(yField);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeMemberProperty&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberProperty&lt;/strong&gt; deklarujemy właściwości klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//X Property&lt;/span&gt;&lt;br /&gt;CodeMemberProperty xProperty = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMemberProperty();&lt;br /&gt;xProperty.Attributes = MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Public&lt;/span&gt; | MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Final&lt;/span&gt;;&lt;br /&gt;xProperty.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"X"&lt;/span&gt;;&lt;br /&gt;xProperty.HasGet = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;xProperty.HasSet = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;xProperty.Type = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReference(typeof(System.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Double&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;xProperty.GetStatements.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMethodReturnStatement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"x"&lt;/span&gt;)));&lt;br /&gt;&lt;br /&gt;xProperty.SetStatements.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeAssignStatement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"x"&lt;/span&gt;),&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodePropertySetValueReferenceExpression()));&lt;br /&gt;&lt;br /&gt;targetClass.Members.Add(xProperty);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Y Property&lt;/span&gt;&lt;br /&gt;CodeMemberProperty yProperty = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMemberProperty();&lt;br /&gt;yProperty.Attributes = MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Public&lt;/span&gt; | MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Final&lt;/span&gt;;&lt;br /&gt;yProperty.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Y"&lt;/span&gt;;&lt;br /&gt;yProperty.HasGet = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;yProperty.HasSet = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;yProperty.Type = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReference(typeof(System.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Double&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;yProperty.GetStatements.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMethodReturnStatement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"y"&lt;/span&gt;)));&lt;br /&gt;&lt;br /&gt;yProperty.SetStatements.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeAssignStatement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"y"&lt;/span&gt;),&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodePropertySetValueReferenceExpression()));&lt;br /&gt;&lt;br /&gt;targetClass.Members.Add(yProperty);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberProperty&lt;/strong&gt; posiada dwie właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HasGet&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HasSet&lt;/strong&gt; które trzeba ustawić aby wygenerować akcesory &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Get&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Set&lt;/em&gt;. &lt;br /&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetStatements&lt;/strong&gt; jest używana aby dodać kod do akcesora &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Get&lt;/em&gt;. W tym przypadku metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Get&lt;/em&gt; zwraca pole &lt;em style="box-sizing: border-box; outline: none !important;"&gt;this.x&lt;/em&gt;. Aby wygenerować referencję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;this&lt;/strong&gt; używamy klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeThisReferenceExpression&lt;/strong&gt;. &lt;br /&gt;Kolekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetStatements&lt;/strong&gt; zawiera kod ustawiający pole &lt;em style="box-sizing: border-box; outline: none !important;"&gt;this.x&lt;/em&gt;. Aby ustawić wartość trzeba użyć klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeAssignStatement&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeMemberMethod&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMemberMethod&lt;/strong&gt; służy do tworzenia metod. poniższy kod tworzy metodę o nazwie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Divide&lt;/em&gt; która zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double&lt;/strong&gt; i ustawia metodę jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;final&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;public&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeMemberMethod divideMethod = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMemberMethod();&lt;br /&gt;divideMethod.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Divide"&lt;/span&gt;;&lt;br /&gt;divideMethod.ReturnType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReference(typeof(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;));&lt;br /&gt;divideMethod.Attributes = MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Public&lt;/span&gt; | MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Final&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy mamy już sygnaturę metody to należy utworzyć jej ciało. Metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Divide&lt;/em&gt; sprawdza czy właściwość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Y&lt;/em&gt; jest równa 0, jeżeli tak to zwraca 0, w przeciwnym wypadku iloraz. Logika &lt;em style="box-sizing: border-box; outline: none !important;"&gt;If&lt;/em&gt; jest utworzona za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeConditonStatement&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeConditionStatement ifLogic = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeConditionStatement();&lt;br /&gt;&lt;br /&gt;ifLogic.Condition = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeBinaryOperatorExpression(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), yProperty.Name),&lt;br /&gt;    CodeBinaryOperatorType.ValueEquality,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodePrimitiveExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;ifLogic.TrueStatements.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMethodReturnStatement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodePrimitiveExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)));&lt;br /&gt;&lt;br /&gt;ifLogic.FalseStatements.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMethodReturnStatement(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeBinaryOperatorExpression(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), xProperty.Name),&lt;br /&gt;        CodeBinaryOperatorType.Divide,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(), yProperty.Name))));&lt;br /&gt;&lt;br /&gt;divideMethod.Statements.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Add&lt;/span&gt;(ifLogic);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeParameterDeclarationExpression i CodeMethodInvokeExpression&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Następnym krokiem jest utworzenie metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Exponent&lt;/em&gt;. Metoda ta pobiera parametr o nazwie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;power&lt;/em&gt; i zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;this.Y&lt;/em&gt; podniesione do potęgi o wartości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;power&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeMemberMethod exponentMethod = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMemberMethod();&lt;br /&gt;&lt;br /&gt;exponentMethod.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Exponent"&lt;/span&gt;;&lt;br /&gt;exponentMethod.ReturnType = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReference(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;typeof&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;double&lt;/span&gt;));&lt;br /&gt;exponentMethod.Attributes = MemberAttributes.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Public&lt;/span&gt; | MemberAttributes.Final;&lt;br /&gt;&lt;br /&gt;CodeParameterDeclarationExpression powerParameter =&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeParameterDeclarationExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;typeof&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;double&lt;/span&gt;), &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"power"&lt;/span&gt;);&lt;br /&gt;exponentMethod.Parameters.Add(powerParameter);&lt;br /&gt;&lt;br /&gt;CodeMethodInvokeExpression callToMath = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMethodInvokeExpression(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeTypeReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"System.Math"&lt;/span&gt;),&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Pow"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeFieldReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeThisReferenceExpression(),&lt;br /&gt;        xProperty.Name), &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeArgumentReferenceExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"power"&lt;/span&gt;));&lt;br /&gt;&lt;br /&gt;exponentMethod.Statements.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeMethodReturnStatement(callToMath));&lt;br /&gt;&lt;br /&gt;targetClass.Members.Add(exponentMethod);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parametr &lt;em style="box-sizing: border-box; outline: none !important;"&gt;power&lt;/em&gt; tworzymy za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeParameterDeclarationExpression&lt;/strong&gt;. &lt;br /&gt;Wywołanie metody i wstawienie do niej parametrów jest realizowane za pomocą klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeMethodInvokeExpression&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;CodeDOMProvider&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ostatnim krokiem jest wygenerowanie pliku klasy. Do utworzenia pliku klasy używamy klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOMProvider&lt;/strong&gt;. Klasa ta posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GenerateCodeFromCompileUnit&lt;/strong&gt; która pobiera jako parametry obiekty klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeCompileUnit&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriter&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeGeneratorOptions&lt;/strong&gt;. Klasa&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeGeneratorOptions&lt;/strong&gt; posiada właściwości pozwalające na kontrole formatowania kodu. Poniższy przykład mówi kompilatorowi aby użył interlinii pomiędzy deklaracjami. Ustawia właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BracingStyle&lt;/strong&gt; na wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“C”&lt;/em&gt;, która mówi, że nawiasy mają być w osobnych liniach.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;CodeDOMProvider provider = CodeDOMProvider.CreateProvider(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CSharp"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;CodeGeneratorOptions &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;options&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CodeGeneratorOptions();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;options&lt;/span&gt;.BlankLinesBetweenMembers = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;options&lt;/span&gt;.BracingStyle = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"C"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;using (StreamWriter sourceWriter = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; StreamWriter(@&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"c:\CodeDOM\Calculator."&lt;/span&gt; +&lt;br /&gt;    provider.FileExtension))&lt;br /&gt;{&lt;br /&gt;    provider.GenerateCodeFromCompileUnit(codeCompileUnit, sourceWriter, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;options&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Lampda Expressions&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Lambda&lt;/strong&gt; są skróconą składnią pisania metod anonimowych. Wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Lambda&lt;/strong&gt; są bardzo często używane w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LINQ&lt;/strong&gt; więc ich zrozumienie jest bardzo ważne.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Delegaty&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Delegata jest typem który przechowuje referencje do metod. Kiedy deklarujemy delegatę, określamy sygnaturę metod jakie maja być przechowywane przez delegatę. &lt;br /&gt;Przykładowo utwórzmy metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WriteToConsoleForward&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;WriteToConsoleForward&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; stringToWrite)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is my string: {0}"&lt;/span&gt;, stringToWrite);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli chcielibyśmy zapisać referencję do tej metody to musielibyśmy utworzyć delegatę o takiej samej sygnaturze, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MyFirstDelegate&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; s&lt;/span&gt;)&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Teraz możemy powiązać zmienną utworzonego typu z metodą:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;MyFirstDelegate myFirstDelegate = new&lt;br /&gt;    MyFirstDelegate&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LambdaExpressions&lt;/span&gt;.WriteToConsoleForward)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Teraz zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;myFirstDelegate&lt;/em&gt; zasadniczo posiada odniesienie do metody. &lt;br /&gt;Teraz możemy wywołać metodę używając zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;myFirstDelegate&lt;/em&gt; i wstawiając do niej parametr:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;myFirstDelegate&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Utwórzmy teraz kolejną metodę o takiej samej sygnaturze:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;WriteToConsoleBackwards&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; stringToWrite)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;[] charArray = stringToWrite.ToCharArray();&lt;br /&gt;    Array.Reverse(charArray);&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is my string backwards: {0}"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;(charArray));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ metoda posiada taką samą sygnaturę to referencja do niej może być przechowywane przez tą samą delegatę.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Stwórzmy metodę która przyjmuje delegatę jako parametr i wywołuje metodę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;WriteToConsole&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(MyFirstDelegate myDelegate, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; stringToWrite)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    myDelegate(stringToWrite);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Teraz możemy wywołać metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WriteToConsole&lt;/em&gt; i wstawić metodę jako parametr:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;WriteToConsole&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LambdaExpressionExample&lt;/span&gt;.WriteToConsoleForward, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;WriteToConsole&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;LambdaExpressionExample&lt;/span&gt;.WriteToConsoleBackwards, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;This is my string: Hello World &lt;br /&gt;This is my string backwards: dlroW olleH&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Ważną rzeczą dotyczącą delegat jest koncept kowariancji i kontrawariancji.&lt;/strong&gt;&lt;br /&gt;Kowariancja pozwala na posiadanie metod z typem zwracanym który jest odziedziczony z typu który jest zadeklarowany w delegacie. Więc typ delegaty może być klasą bazową a typ zwracany przez metody może dziedziczyć z tego typu bazowego. &lt;br /&gt;Kontrawariancja pozwala na posiadanie parametrów typu który jest klasą bazową dla typu zdefiniowanego w delegacie. Więc typ parametru metody może być klasa bazową pod warunkiem, że parametr delegaty jest typu dziedziczącego z tej klasy bazowej.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Metody anonimowe&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody anonimowe pozwalają na deklarację delegaty i bezpośrednie przypisanie do niej metody w tej samej linii kodu, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MyFirstDelegate&lt;/span&gt; forward = delegate(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string &lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;s2&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is my string: {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;s2&lt;/span&gt;)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;}&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;forward&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jedną z różnic między metodą anonimową a delegata jest to, że można w niej odnosić się do zmiennych lokalnych które nie zostały przekazane jako parametr. &lt;br /&gt;Poniższy kod demonstruje utworzenie delegaty bez parametrów i użycie zmiennej lokalnej w metodzie anonimowej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;delegate &lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MyAnonymousMethod&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt; myLocalString = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Create&lt;/span&gt; an anonymous &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; the local variable.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MyAnonymousMethod&lt;/span&gt; forward = delegate()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Format&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is my string: {0}"&lt;/span&gt;, myLocalString));&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    forward();&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Lambda Expressions&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia lambda pozwalają na tworzenie metod anonimowych używając skróconej notacji, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;square&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; x)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    square myLambdaExpression = x =&amp;gt; x * x;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"X squared is {0}"&lt;/span&gt;, myLambdaExpression(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażeniem lambda z przykładu jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;x =&amp;gt; x &lt;/em&gt;x*. Operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;=&amp;gt;&lt;/strong&gt; nazywany jest operatorem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;goes to&lt;/em&gt;. Lewa strona operatora zawiera parametry wejściowe metody. Ciało metody zapisywane jest po prawej stronie operatora. Jeżeli używamy kilku parametrów to zapisujemy je w nawiasie oddzielając je przecinkami, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GreaterThan&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; x, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; y)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    GreaterThan gt = (x, y) =&amp;gt; x &amp;gt; y;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Is 6 greater than 5. {0}"&lt;/span&gt;, gt(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli metoda zawiera tylko jedno wyrażenie to nazywamy takie wyrażenie wyrażeniem lambda (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;expression lambda&lt;/em&gt;). &lt;br /&gt;Jeżeli metoda wymaga użycia wielu wyrażeń w swoim ciele to takie nazywamy ją deklaracją lambda (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;statement lambdas&lt;/em&gt;) i otaczamy nawiasem klamrowym &lt;em style="box-sizing: border-box; outline: none !important;"&gt;{ }&lt;/em&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;s =&amp;gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;char&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; charArray = s.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ToCharArray&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Array&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Reverse&lt;/span&gt;(charArray);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is my string to write backwards: {0}"&lt;/span&gt;,&lt;br /&gt;            new &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;(charArray));&lt;br /&gt;    };&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można użyć wyrażenia lambda aby wstawić funkcję do metody. poniższy przykład używa wyrażenia lambda do wywołania metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WriteToConsole&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;WriteToConsole&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;x&lt;/span&gt; =&amp;gt; Console.WriteLine&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This is my string {0}"&lt;/span&gt;, x)&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;)&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Refleksja(ang. Reflection)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Istnieja dwa sposoby aby pobrać referencję do typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Type&lt;/strong&gt; obiektu. Używając na obiekcie metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;typeof()&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.GetType()&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można uzyć klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Reflection.Assembly&lt;/strong&gt; aby zbadać typy w pliku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;EXE&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DLL&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly.Load&lt;/strong&gt; pobiera assembly do pamięci i pozwala na wykonanie jej kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly.ReflectionOnlyLoad&lt;/strong&gt; pobiera assembly do pamięci ale nie pozwala na wykonanie jej kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assembly.CreateInstance&lt;/strong&gt; tworzy instancję typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Type&lt;/strong&gt; reprezentuje klasę, interfejs, tablicę, typ wartości, enumerację, parametr i typ generyczny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Type.GetProperty&lt;/strong&gt; zwraca obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PropertyInfo&lt;/strong&gt; i pozwala na pobranie i ustawianie wartości właściwości.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Atrybuty&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Atrybuty służą do tworzenia metadanych dla klas, właściwości i metod.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Atrybuty definiuje się w nawiasach kwadratowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;[]&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Atrybuty niestandardowe muszą dziedziczyć z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Attribute&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Code Document Object Model (CodeDOM)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Przestrzeń nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CodeDOM&lt;/strong&gt; zawiera klasy które pozwalają tworzyć generatory kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.CodeDom.CodeCompileUnit&lt;/strong&gt; jest kontenerem dla kodu który chcemy wygenerować.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.CodeDom.CodeDOMProvider&lt;/strong&gt; generuje plik klasy w wybranym z języków: &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VB&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;JScript&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Lambda expressions&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyrażenie lambda są skróconą notacją dla metod anonimowych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Delegata jest typem który przechowuje referencje do metod.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kowariancja pozwala na posiadanie metod z typem zwracanym który jest odziedziczony z typu który jest zadeklarowany w delegacie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kontrawariancja pozwala na posiadanie parametrów typu który jest klasą bazową dla typu zdefiniowanego w delegacie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;=&amp;gt;&lt;/strong&gt; jest odczytywany jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;“goes to”&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Sat, 23 Jan 2016 21:39:23 Z</pubDate>
      <a10:updated>2016-01-23T21:39:23Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1124</guid>
      <link>http://smsoft.pl/blog/vi-wielowatkowosc-i-przetwarzanie-asynchroniczne/</link>
      <title>VI. Wielowątkowość i przetwarzanie asynchroniczne</title>
      <description>&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;div&gt;&lt;span style="color: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 32px;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task Parallel Library&lt;/strong&gt; (ParallelFor, Plinq, Tasks).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThreadPool&lt;/strong&gt; i obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Thread&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Odblokowywanie UI przy użyciu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BackgroundWorker&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie słów kluczowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zarządzanie danymi za pomocą równoległych kolekcji. Użycie klas z przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Concurrent.Collections&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Synchronizacja zasobów za pomocą klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ManualResetEvent&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AutoResetEvent&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Implementacja blokowania za pomocą klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Mutex&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Semaphore&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Przerywanie długich zadań za pomocą klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationToken&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Tworzenie responsywnych aplikacji&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pierwsze komputery zostały stworzone w architekturze nazywanej architekturą von Newmann’a. Komputry te posiadały jedną jednostkę przetwarzania, moduł sterujący, pamięć i system wejścia i wyjścia (IO). Ponieważ posiadały tylko jedną jednostkę przetwarzania to programy pisane na tą architekturę musiały być bisane tak aby były wykonywane sekwencyjnie. taki rodzaj programowania jest używany do dzisiaj. Największą wadą takiego podejścia jest to, że ilekroć aplikacja musi czekać aż coś się wykona to cały system zostaje zatrzymany, tworząc bardzo nieprzyjemne doświadczenie użytkownika. Wątki zostały wprowadzone aby zminimalizować tego rodzaju problemy.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Praca z wątkami&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy aplikacja pobiera dane z &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt; czeka na dane które maja być odebrane nie wykonując w tym czasie żadnych obliczeń. Aby polepszyć responsywność aplikacji została wprowadzona wielowątkowość. W aplikacjach wielowątkowych jeden wątek tworzy następny wątek który pobiera dane &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; i czeka aż ojczysty wątek powróci aby wykonywać dalszą pracę. Kiedy dane są potrzebne to ojczysty wątek jest zablokowany czekając aż utworzony wątek zakończy pracę. Ten wzorzec jest nazywany &lt;em style="box-sizing: border-box; outline: none !important;"&gt;fork-join&lt;/em&gt;. &lt;br /&gt;Jeżeli mamy do dyspozycji jeden procesor to oznacza, że tylko jeden wątek może być wykonywany w danym punkcie czasu. Może to być osiągnięte na dwa różne sposoby:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Grupowo - każdy wątek musi zrezygnować z kontroli, tak aby inny wątek mógł być wykonany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapobiegawczo - system operacyjny posiada komponent zwany &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;scheduler&lt;/strong&gt; który sprawdza czy żaden wątek nie monopolizuje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt;. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows&lt;/em&gt; jest zbudowany w ten sposób.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Algorytm działania harmonogramu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows&lt;/em&gt;:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Każdy wątek posiada priorytet nadany przy jego tworzeniu. Tworzony wątek nie jest startowany automatycznie, trzeba go uruchomić.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy wątek jest wystartowany, zostaje dodany do kolejki wszystkich wątków które mogą być uruchomione.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Harmonogram pobiera wątek z najwyższym priorytetem w kolejce i uruchamia go.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli kilka wątków posiada ten sam priorytet to harmonogram rozkłady je w kołowym porządku (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;round robin&lt;/em&gt;).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy upływa przeznaczony czas, harmonogram wstrzymuje wątek i dodaje go na koniec kolejki. Po tym pobiera kolejny wątek z kolejki i uruchamia go.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli nie ma innego wątku z wyższym priorytetem niż ten wstrzymany, to ten wątek zostaje wykonywany ponownie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy wątek jest blokowany i czeka na operację &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; lub jest blokowany z innego powodu to wątek ten jest usuwany z kolejki i następny wątek jest uruchamiany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy zablokowany wątek zostaje odblokowany to wraca z powrotem do kolejki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy wątek zostaje zakończony to harmonogram pobiera kolejny wątek do uruchomienia.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieje jeden wątek nazywany &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System idle process&lt;/strong&gt; (Proces bezczynności systemu), który nie robi nic oprócz trzymania procesora jako zajętego kiedy ten nie posiada żadnych innych wątków do uruchomienia. &lt;br /&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; wszystkie aplikacje posiadają kilka wątków. Oto lista niektórych z nich:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Garbage Collector thread&lt;/strong&gt; - wątek czyszczenia pamięci.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalizer thread&lt;/strong&gt; - uruchamia metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; w obiektach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Main thread&lt;/strong&gt; - uruchamia metody główne aplikacji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;UI thread&lt;/strong&gt; - aktualizuje interfejs użytkownika. &lt;br /&gt;Poza wątkiem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Main&lt;/strong&gt; wszystkie pozostałe wymienione watki są wątkami wykonywanymi w tle. Tworząc nowy wątek masz możliwość określenia, czy wątek powinien być wątkiem wykonywanym w tle. &lt;br /&gt;Kiedy wątek główny i wszystkie wątki które nie są wątkami tła zostają zakończone to aplikacja również zostaje zakończona.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wielowątkowe aplikacje posiadają również wady, oto najważniejsze z nich:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wszystkie wątki używają zasobów. Potrzebują do pracy dużo pamięci (standardowo 1MB) i za każdym razem kiedy harmonogram przełącza sie pomiędzy wątkami, procesor jest zajęty zapisywaniem kontekstu wstrzymywanego wątku oraz przywróceniem kontekstu wątku uruchamianego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli aplikacja tworzy za dużo wątków to przełączenie kontekstu pochłania dużo czasu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Ponieważ wątki potrzebują dużo pamięci to zwykle ich tworzenie i usuwanie zajmuje sporo czasu dla systemu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; wątki są zaimplementowane w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading.Thread&lt;/strong&gt;. &lt;br /&gt;Praca z tworzeniem wątków odbywa sie w następujący sposób:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Utworzenie obiektu wątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Uruchomienie wątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonanie większej ilości pracy w metodzie wywołującego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Czekanie aż wątek się zakończy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kontynuacja pracy metody wywołującej.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład aplikacji symulującej wykonywanie dwóch rzeczy: czytania &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; i wykonywania intensywnych obliczeń:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Program&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;[] args) {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt; to time the code&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt; sw = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StartNew&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Here&lt;/span&gt; we call different methods&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; different ways &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; running our application.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunSequencial&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the time it took to run the application.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"We're done sequencial in {0}ms!"&lt;/span&gt;, sw.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ElapsedMilliseconds&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt; to time the code&lt;br /&gt;        sw = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StartNew&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Here&lt;/span&gt; we call different methods&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; different ways &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; running our application.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWithThreads&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the time it took to run the application.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"We're done with threads in {0}ms!"&lt;/span&gt;, sw.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ElapsedMilliseconds&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Debugger&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;IsAttached&lt;/span&gt;) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Press any key to continue . . ."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadKey&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;true&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunSequencial&lt;/span&gt;() {&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Call&lt;/span&gt; the function to read data &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; I/O&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/span&gt;();&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Add&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; the second calculation&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWithThreads&lt;/span&gt;() {&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Create&lt;/span&gt; the thread to read &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; I/O&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; thread = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Thread&lt;/span&gt;(() =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/span&gt;());&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Start&lt;/span&gt; the thread&lt;br /&gt;        thread.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Start&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Save&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; the calculation into another variable&lt;br /&gt;        double result2 = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Wait&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; the thread to finish&lt;br /&gt;        thread.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Join&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Calculate&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;end&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += result2;&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; double &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/span&gt;() {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are simulating an I/O by putting the current thread to sleep.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Thread&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Sleep&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5000&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;d;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; double &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;(){&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are simulating intensive calculations&lt;br /&gt;        // by doing nonsens divisions&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;100000000&lt;/span&gt;d;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; maxValue = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Int32&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MaxValue&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i=&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; i &amp;lt; maxValue; i++){&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; /= i;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;d;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;The result is 20 &lt;br /&gt;We’re done sequencial in 16489ms! &lt;br /&gt;The result is 20 &lt;br /&gt;We’re done with threads in 11388ms!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie ThreadPool&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ wątki są zasobami drogimi w utrzymaniu to aby ulepszyć wydajność aplikacji, można wybrać wątki już utworzone przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; które są dostępne w puli wątków. Służy do tego klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading.ThreadPool&lt;/strong&gt;. Klasa ta posada tylko etody statyczne, najważniejsze z nich to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetAvailableThreads&lt;/strong&gt; - zwraca liczbę wątków dostępnych w puli wątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMaxThreads&lt;/strong&gt; - zwraca maksymalną liczbę wątków jaką może utworzyć pula wątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetMinThreads&lt;/strong&gt; - zwraca minimalną liczbę wątków jaką może utworzyć pula wątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;QueueUserWorkItem&lt;/strong&gt; - dodaje żądanie o wykonanie do kolejki puli wątków. jJeżeli istnieją wolne wątki w puli to żądanie zostanie wykonane natychmiast.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RegisterWaitForSingleObject&lt;/strong&gt; - rejestruje metodę do wywołania, gdy albo określony, jako pierwszy parametr &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitHandle&lt;/strong&gt; zostanie zasygnalizowany lub gdy limit czasu określony jako czwarty parametr upłynie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetMaxThreads&lt;/strong&gt; - ustawia maksymalną liczbę wątków które mogą być utworzone w puli.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetMinThreads&lt;/strong&gt; - ustawia minimalną liczbę wątków dostępnych w puli w określonym czasie.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Powyższa lista nie jest kompletna. Najważniejsza z tej listy metoda to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;QueueUserWorkItem&lt;/strong&gt;. &lt;br /&gt;Pula wątków działa w następujący sposób. Kiedy potrzebujesz odseparowanego wątku na wykonanie długotrwałej metody, to zamiast tworzyć nowy wątek, wywołujesz metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;QueueUserWorkItem&lt;/strong&gt; w celu umieszczenie nowego elementu pracy w kolejce zarządzanej przez pulę wątków. Jeżeli w kolejce jest bezczynny wątek to startuje element pracy i wykonuje go tak samo jak każdy inny wątek. Jeżeli nie ma dostępnego wolnego wątku i liczba wątków w puli jest mniejsza niż &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MaxThreads&lt;/strong&gt;, to pula tworzy nowy wątek który uruchomi element pracy. W przeciwnym wypadku element pracy czeka w kolejce na wolny wątek. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SetMinThread&lt;/strong&gt; jest używana aby poprawić wydajność pracy aplikacji jeżeli wiemy, że będziemy używać puli wątków. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;QueueUserWorkItem&lt;/strong&gt; posiada dwa przeciążenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;bool&lt;/span&gt; QueueUserWorkItem(WaitCallback callBack)&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;bool&lt;/span&gt; QueueUserWorkItem(WaitCallback callBack, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;Object&lt;/span&gt; state)&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parametr &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading.WaitCallback&lt;/strong&gt; jest delegatą zdefiniowaną następująco:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public delegate void WaitCallback(Object &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;state&lt;/span&gt;)&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieją pewne różnice pomiędzy wątkami utworzonymi manualnie a wątkami z puli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThreadPool&lt;/strong&gt;, są to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wszystkie wątki z puli wątków są wątkami wykonywanymi w tle, natomiast wątki utworzone manualnie są domyślnie wątkami pierwszoplanowymi ale mogą być ustawione jako watki wykonywane w tle.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie można przerwać lub anulować wątku z puli wątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie możesz dołączyć wątku z puli wątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wątki z puli po zakończeniu pracy trafiają z powrotem do kolejki i mogą być użyte ponownie natomiast wątki utworzone manualnie są niszczone po zakończeniu pracy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie można kontrolować priorytetu wątków z puli wątków.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Maksymalna liczba wątków w puli jest różna dla różnych wersji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; i powinna być traktowana jako detal implementacyjny. W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 2.0&lt;/em&gt; jest 25 wątków na rdzeń, w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 3.5&lt;/em&gt; jest 250 a w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4&lt;/em&gt; jest 1023 dla 32 bitowych aplikacji i 32,767 dla 64 bitowych. &lt;br /&gt;Przykład metody z poprzedniej sekcji wykonującej odczyt z &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; w osobnym wątku napisanej za pomącą puli wątków:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunInThreadPool&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Create&lt;/span&gt; a work item to read &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; I/O&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ThreadPool&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;QueueUserWorkItem&lt;/span&gt;((x) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/span&gt;());&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Save&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; the calculation into another variable&lt;br /&gt;    double result2 = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Wait&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; the thread to finish&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;TODO&lt;/span&gt;: &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; will need a way to indicate&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;when&lt;/span&gt; the thread pool thread finished the execution&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Calculate&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;end&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += result2;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThreadPool.QueueUserWorkItem&lt;/strong&gt; wstawia jednostkę pracy do kolejki zarządzanej przez pulę wątków. kiedy wątek z puli jest dostępny to pobiera jednostkę i wykonuje ją aż do jej zakończenia. Jedynym problemem jest to, że nie wiadomo kiedy wątek zakończy swoją pracę. Nie istnieje metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Join&lt;/strong&gt; ani nic podobnego. Aby rozwiązać ten problem nalerzy użyć jakiegoś mechanizmu sygnalizującego koniec pracy. &lt;br /&gt;Bardzo często nie chcemy używać klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThreadPool&lt;/strong&gt; bezpośrednio. Zamiast tego można użyć innych technologii zbudowanych na jej podstawie jak T&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ask Parallel Library&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TPL&lt;/strong&gt;), &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Asynchronous Pattern Model&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;APM&lt;/strong&gt;), &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Eventbased Asynchronous Pattern&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EAP&lt;/strong&gt;), &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task-based Asynchronous Pattern Model&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TAP&lt;/strong&gt;), lub nowych słów kluczowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Odblokowywanie interfejsu użytkownika&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jednym z największych problemów aplikacji jest to, że mogą przestać odpowiadać. Aby temu zapobiec można przetwarzać czasochłonne operacje w osobnych wątkach. Istnieje wiele wzorców programowania asynchronicznego które stosuje się aby tego dokonać. &lt;br /&gt;Aplikacje od wersji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.5&lt;/em&gt; posiadają nowy model programowania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async/await&lt;/strong&gt;. Jeżeli aplikacja napisana jest w niższej wersji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Frameworka&lt;/em&gt; to niestety trzeba samemu zadbać o asynchroniczność.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Klasa BackgroundWorker&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 2.0&lt;/em&gt; prowadził klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.ComponentModel.BackgroundWorker&lt;/strong&gt; która abstrahuje tworzenie wątku i wykorzystanie puli wątków. &lt;br /&gt;Przydatne metody tej klasy to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerAsync&lt;/strong&gt; - rejestruje żądanie wystartowania operacji w tle.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReportProgress&lt;/strong&gt; - zgłasza zdarzenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProgressChanged&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancelAsync&lt;/strong&gt; - rejestruje żądanie anulowania operacji w tle.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przydatne właściwości tej klasy to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationPending&lt;/strong&gt; - ustawione na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli wywołana została metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancelAsync&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsBusy&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunAsync&lt;/strong&gt; została uruchomiona i operacja nie została jeszcze ukończona.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WorkerReportsProgress&lt;/strong&gt; - ustawienie na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; powoduje raportowanie postępu przez operację wykonywaną w tle.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WorkerSupportsCancellation&lt;/strong&gt; - ustawienie na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; umożliwia wsparcie dla anulowania operacji.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przydatne zdarzenia tej klasy to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DoWork&lt;/strong&gt; - wyzwalane kiedy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerAsync&lt;/strong&gt; jest wywoływany. tutaj wykonuje się długotrwałe operacje.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProgressChanged&lt;/strong&gt; - wyzwalane kiedy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReportProgress&lt;/strong&gt; jest wywoływany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerCompleted&lt;/strong&gt; - wyzwalane kiedy operacja jest zakończona, również przez anulowanie lub wyjątek.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Algorytm pracy z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BackgroundWorker&lt;/strong&gt; jest następujący:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy metodę o sygnaturze &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DoWorkEventHandler&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W tej metodzie wywołujemy długotrwałą operację. Kiedy metoda się zakonczy to przypisujemy wynik operacji do właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Result&lt;/strong&gt; parametru &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DoWorkEventArgs&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy instancję klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BackgroundWorker&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapisujemy utworzoną metodę do zdarzenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DoWork&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy metodę o sygnaturze &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerCompletedEventHandler&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W tej metodzie pobieramy wynik długotrwałej operacji i aktualizujemy UI.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapisujemy tę metodę do zdarzenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerCompleted&lt;/strong&gt;. Jeżeli operacja wyrzuciła wyjątek to znajdziemy go we właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Error&lt;/strong&gt; parametru &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerCompletedEventArgs&lt;/strong&gt;, w przeciwnym wypadku właściwość ta ma wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli chcemy śledzić postęp wykonania operacji to tworzymy metodę o sygnaturze &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProgressChangedEventHandler&lt;/strong&gt; i zapisujemy ją do zdarzenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProgressChanged&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Startujemy proces w tle poprzez uruchomienie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerAsync&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Możemy użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancelAsync&lt;/strong&gt; do anulowania zadania.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Załóżmy, że mamy aplikację &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows Forms&lt;/em&gt; która posiada formularz z etykietą o nazwie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;lblResult&lt;/em&gt; i guzikiem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;btnRun&lt;/em&gt;. Przykładowo długotrwałe zadanie z użyciem klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BackgroundWorker&lt;/strong&gt; może wyglądać tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public partial class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Form1&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Form&lt;/span&gt; {&lt;br /&gt;    private &lt;span style="box-sizing: border-box; outline: none !important;"&gt;BackgroundWorker&lt;/span&gt; worker;&lt;br /&gt;&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Form1&lt;/span&gt;() {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InitializeComponent&lt;/span&gt;();&lt;br /&gt;        worker = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;BackgroundWorker&lt;/span&gt;();&lt;br /&gt;        worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoWork&lt;/span&gt; += worker_DoWork;&lt;br /&gt;        worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWorkerCompleted&lt;/span&gt; += worker_RunWorkerCompleted;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; worker_DoWork(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoWorkEventArgs&lt;/span&gt; e) {&lt;br /&gt;        e.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; worker_RunWorkerCompleted(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWorkerCompletedEventArgs&lt;/span&gt; e) {&lt;br /&gt;        lblResult.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Text&lt;/span&gt; = e.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Result&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ToString&lt;/span&gt;());&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private &lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; btnRun_Click(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;EventArgs&lt;/span&gt; e) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;IsBusy&lt;/span&gt;) {&lt;br /&gt;            worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWorkerAsync&lt;/span&gt;();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; double &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;() {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are simulating intensive calculations&lt;br /&gt;        // by doing nonsens divisions&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;100000000&lt;/span&gt;d;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; maxValue = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Int32&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MaxValue&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; i &amp;lt; maxValue; i++) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; /= i;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;d;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wielowątkowe aplikacje Windows Forms&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aplikacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows Forms&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; posiadają dedykowany wątek do aktualizacji interfejsu użytkownika. Zapobiega on sytuacjom w których więcej niż jeden wątek próbuje dostać się do tego samego wspólnego zasobu. Taka sytuacja nazywana jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;race conditions&lt;/strong&gt;. Jeżeli próbujemy aktualizować UI z innego wątku to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; wyrzuci wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidOperationException&lt;/strong&gt; z informacją &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“Cross-thread operation not valid: Control ‘ctrlName’ accessed from a thread other than the thread it was created on.”&lt;/em&gt;&lt;br /&gt;Kod z poprzedniej sekcji działał ponieważ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BackgroundWorker&lt;/strong&gt; został uruchomiony z wątku UI. Jeżeli zostałby uruchomiony z innego wątku to otrzymalibyśmy wyjątek. Aby rozwiązać ten problem należy zmodyfikować metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;worker_RunWorkerCompleted&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;worker_RunWorkerCompleted&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, RunWorkerCompletedEventArgs e&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.InvokeRequired) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Invoke(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt;(UpdateLabel),&lt;br /&gt;            e.Result.ToString());&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt; {&lt;br /&gt;        UpdateLabel(e.Result.ToString());&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;UpdateLabel&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; text&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;    lblResult.Text = text;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvokeRequired&lt;/strong&gt; jest zdefiniowana w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Control&lt;/strong&gt; i zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli jest sprawdzana w innym wątku niż wątek UI. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Invoke&lt;/strong&gt; również należy do klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Control&lt;/strong&gt; i przyjmuje jako pierwszy parametr delegatę. metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Invoke&lt;/strong&gt; umieszcza metodę w kolejce wątku UI.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wielowątkowe aplikacje WPF&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aplikacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; tak jak aplikacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows Forms&lt;/em&gt; posiadają wątek odpowiedzialny za aktualizację UI. Dodatkowo aplikacje &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; posiadają prywatny wątek renderowania UI. &lt;br /&gt;Przykładowa aplikacja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; wykonująca metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculation&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public partial class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MainWindow&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Window&lt;/span&gt; {&lt;br /&gt;    private &lt;span style="box-sizing: border-box; outline: none !important;"&gt;BackgroundWorker&lt;/span&gt; worker;&lt;br /&gt;&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MainWindow&lt;/span&gt;() {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InitializeComponent&lt;/span&gt;();&lt;br /&gt;        worker = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;BackgroundWorker&lt;/span&gt;();&lt;br /&gt;        worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoWork&lt;/span&gt; += worker_DoWork;&lt;br /&gt;        worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWorkerCompleted&lt;/span&gt; += worker_RunWorkerCompleted;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; worker_RunWorkerCompleted(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWorkerCompletedEventArgs&lt;/span&gt; e) {&lt;br /&gt;        lblResult.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Content&lt;/span&gt; = e.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Result&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; worker_DoWork(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoWorkEventArgs&lt;/span&gt; e) {&lt;br /&gt;        e.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private &lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; btnRun_Click(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;EventArgs&lt;/span&gt; e) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;IsBusy&lt;/span&gt;) {&lt;br /&gt;            worker.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunWorkerAsync&lt;/span&gt;();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; double &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;() {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are simulating intensive calculations&lt;br /&gt;        // by doing nonsens divisions&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;100000000&lt;/span&gt;d;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; maxValue = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Int32&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MaxValue&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; i &amp;lt; maxValue; i++) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; /= i;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;d;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jedyną różnicą jest sposób aktualizacji etykiety. Zamiast aktualizacji właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Text&lt;/em&gt; aktualizujemy właściwość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Content&lt;/em&gt;. Niestety aplikacja &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; również wyrzuca wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidOperationException&lt;/strong&gt; z informacją &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“The calling thread cannot access this object because a different thread owns it.”&lt;/em&gt; jeżeli aktualizujemy wątek UI z innego wątku. Rozwiązanie wygląda następująco:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Dispatcher.Invoke(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;=&amp;gt;&lt;/span&gt; lblResult.Content = e.Result);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Praca z Task Parallel Library&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4&lt;/em&gt; została wprowadzona klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; która reprezentuje operację asynchroniczną. Klasa ta została wprowadzona w celu abstrahowania programisty od wątków. Używa ona wątków z puli wątków ale oferuje dużą kontrolę i elastyczność w tym jak zadania są tworzone. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task &lt;/strong&gt;znajduje się w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Treading.Tasks&lt;/strong&gt;. Istnieją dwie klasy zadań: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&amp;lt;TResult&amp;gt;&lt;/strong&gt;. Pierwsza z nich jest używana kiedy wykonujemy w zadaniu metodę i nie potrzebujemy zwracanej wartości, drugą używamy kiedy metoda zwraca wynik.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej używane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContinueWith&lt;/strong&gt; - tworzy nowe zadanie które będzie uruchomione asynchroniczne kiedy aktualne zadanie się zakończy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Delay&lt;/strong&gt; - metoda statyczna tworząca zadanie które jest oznaczone jako zakończone po wyznaczonym opóźnieniu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Run&lt;/strong&gt; - metoda statyczna wysyłająca żądanie do puli wątków i zwracająca obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Start&lt;/strong&gt; - startuje zadanie reprezentowane przez tą instancję klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Wait&lt;/strong&gt; - czeka na zakończenie zadania wykonywanego przez tą instancję klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitAll&lt;/strong&gt; - metoda statyczna czekająca na wykonanie wszystkich zadań wysłanych jako parametr.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitAny&lt;/strong&gt; - metoda statyczna czekająca na wykonanie któregokolwiek z zadań wysłanych jako parametr.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WhenAll&lt;/strong&gt; - metoda statyczna tworząca zadanie oznaczone jako zakończone kiedy wszystkie zadania wysłane jako parametr zostaną zakończone.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WhenAny&lt;/strong&gt; - metoda statyczna tworząca zadanie oznaczone jako zakończone kiedy którekolwiek zadanie wysłane jako parametr zostanie zakończone.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej używane właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CurrentId&lt;/strong&gt; - statyczna właściwość tylko do odczytu, identyfikator wykonywanego zadania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; - właściwość tylko do odczytu zawierająca nieobsługiwany wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AggregateException&lt;/strong&gt;, jeśli &lt;br /&gt;wystąpił wyjątek który spowodował zakończenie zadania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Factory&lt;/strong&gt; - statyczna właściwość tylko do odczytu zwraca obiekt fabryki który może być użyty do utworzenia nowych zadań.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ID&lt;/strong&gt; - właściwość tylko do odczytu zwracająca identyfikator instancji klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsCanceled&lt;/strong&gt; - właściwość tylko do odczytu posiadająca wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli zadanie zostało zakończone poprzez anulowanie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsCompleted&lt;/strong&gt; - właściwość tylko do odczytu posiadająca wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli zadanie zostało zakończone.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsFaulted&lt;/strong&gt; - właściwość tylko do odczytu posiadająca wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli zadanie zostało zakończone przez nieobsłużony wyjątek.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Status&lt;/strong&gt; - właściwość tylko do odczytu zwracająca status zadania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Result&lt;/strong&gt; - właściwość tylko do odczytu zwraca wartość zwracaną przez operację asynchroniczną reprezentowaną poprzez to zadanie.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Statyczna właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Factory&lt;/strong&gt; jest typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskFactory&lt;/strong&gt; i jest używana do tworzenia nowych zadań. Najczęściej wykorzystywane metody tej klasy to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContinueWhenAll&lt;/strong&gt; - tworzy nowe zadanie które startuje kiedy wszystkie zadania przesłane jako parametr zostaną zakończone.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContinueWhenAny&lt;/strong&gt; - tworzy nowe zadanie które startuje kiedy jakiekolwiek zadanie przesłane jako parametr zostanie zakończone.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FromAsync&lt;/strong&gt; - metoda używana do przeniesienia kodu starego modelu asynchronicznego do modelu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TAP&lt;/strong&gt; poprzez opakowanie wywołania asynchronicznego przez zadanie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StartNew&lt;/strong&gt; - metoda tworząca nowe zadanie i startująca je.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Tworzenie zadań&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zadania możemy tworzyć na kilka sposobów:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można utworzyć instancję obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;. Instancja nie jest automatycznie uruchamiana więc trzeba wywołać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Start&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można użyć jednego z przeciążeń metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskFactory.StartNew&lt;/strong&gt;. Ta metoda tworzy i startuje zadanie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można użyć jednego z przeciążeń statycznej metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.Run&lt;/strong&gt;. Jest to uproszczona wersja metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskFactory.StartNew&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można wywołać jedną z metod kontynuacji jak np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.WhenAll&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.WhenAny&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskFactory.ContinueWhenAll&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskFactory.ContinueWhenAny&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskFactory.StartNew&lt;/strong&gt; oferuje dużą elastyczność. Kiedy tworzymy zadanie musimy przynajmniej określić metodę lub funkcję którą chcemy uruchomić jako zadanie. Ponadto, można określić opcje dotyczące tworzenia zadania, token anulowania i harmonogram kolejki zadań w wątkach. &lt;br /&gt;Enumerator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskCreationOptions&lt;/strong&gt; opisuje opcje tworzenia zadania:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;None&lt;/strong&gt; - domyślne zachowanie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PreferFairness&lt;/strong&gt; - Zadania powinny być zaplanowane w sposób uczciwy. Jest to tylko podpowiedź i oczekiwanym jej rezultatem jest to, że zadania zaplanowane wcześniej będą wykonywane wcześniej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LongRunning&lt;/strong&gt; - Oznacza, że zadanie zajmuje dużo czasu. jest to tylko podpowiedź i oczekiwanym jej rezultatem jest to, że zadania mogą być wykonywane w większej ilości wątków niż dostępna liczba wątków sprzętowych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AttachedToParent&lt;/strong&gt; - Nowe zadanie jest przypięte do zadania rodzica w hierarchii.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DenyChildAttach&lt;/strong&gt; - Oznacza, że żadne podzadania nie mogą być przypięte do tego zadania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HideScheduler&lt;/strong&gt; - Oznacza, że aktualny harmonogram nie powinien być używany przy tworzeniu zadania z tego nowo utworzonego zadania.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Enumerator posiada również atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FlagsAttribute&lt;/strong&gt; oznaczający, że opcje mogą być kombinowane.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład programu wywołującego metodę obliczeniową 32 razy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Program&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;32&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;[] args) {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt; to time the code&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt; sw = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Stopwatch&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StartNew&lt;/span&gt;();&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunSequential&lt;/span&gt;();&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the time it took to run the application.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"We're done in {0}ms!"&lt;/span&gt;, sw.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ElapsedMilliseconds&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunSequential&lt;/span&gt;() {&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Here&lt;/span&gt; we call same &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt; several times.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;; i++) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;        }&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; double &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;() {&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; are simulating intensive calculations&lt;br /&gt;        // by doing nonsens divisions &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;and&lt;/span&gt; multiplications&lt;br /&gt;        double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10000&lt;/span&gt;d;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; maxValue = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Int32&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;MaxValue&lt;/span&gt; &amp;gt;&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; i &amp;lt; maxValue; i++) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (i % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; /= i;&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; *= i;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania programu to:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;The result is 22.0386557304958 &lt;br /&gt;We’re done in 41860ms!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;jak widać wykonanie tego programu trwało 42s. Ulepszmy wydajność tego zadania używając zadań. Aby tego dokonać zastąpimy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunSequential&lt;/strong&gt; za pomocą metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunTasks&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunTasks&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;[] tasks = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;];&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; create one task per iteration.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;; i++) {&lt;br /&gt;        tasks[i] = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(() =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;());&lt;br /&gt;    }&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania programu to:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;The result is 2.75483196631197 &lt;br /&gt;We’re done in 10115ms! &lt;br /&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Jak widać wynik jest niepoprawny. Aplikacja nie jest 8 razy szybsza jak się tego można spodziewać.&lt;/strong&gt;&lt;br /&gt;Powodem dla którego aplikacja nie jest 8 razy szybsza jest to, że używamy nowoczesnego procesora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Intel Core I7&lt;/strong&gt;. Jest to czterordzeniowy procesor z funkcją hyper-threading. Hyperthreading oznacza, że każdy rdzeń ma dwa potoki instrukcji, ale tylko jeden silnik wykonania. System operacyjny widzi to jako 8 różnych procesorów. Hyperthreading poprawia wydajność o około 30%. &lt;br /&gt;Wynik aplikacji jest niepoprawny ponieważ występuje tu zjawisko &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;race conditions&lt;/strong&gt; i zamiast sumowania wyniku każdy wątek go nadpisuje. poprawna wersja metody to:&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunTasksCorrected&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;&amp;lt;double&amp;gt;[] tasks = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;&amp;lt;double&amp;gt;[&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;];&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; create one task per iteration.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;; i++) {&lt;br /&gt;        tasks[i] = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(() =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;());&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; wait &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; the tasks to finish&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WaitAll&lt;/span&gt;(tasks);&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; collect the results&lt;br /&gt;    foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; task &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; tasks) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += task.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Result&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania programu to:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;The result is 22.0386557304958 &lt;br /&gt;We’re done in 10369ms!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wywołanie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.WaitAll(tasks)&lt;/strong&gt; nie jest konieczne ponieważ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;task.Result&lt;/strong&gt; zablokuje pętlę wywołującą jeżeli kalkulacja jeszcze nie została zakończona.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Praca z harmonogramem zadań&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolejkowanie zadań w wątkach jest wykonywane przez komponent zwany harmonogramem zadań (ang. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;task scheduler&lt;/strong&gt;), zaimplementowanym w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskScheduler&lt;/strong&gt;. Normalnie nie używa się go bezpośrednio. Startując zadanie bez wyznaczenia harmonogramu używany jest domyślny. &lt;br /&gt;W aplikacjach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows Forms&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; używa się harmonogramu zadań bezpośrednio. Ponieważ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UI&lt;/em&gt; może być zaktualizowane tylko przez wątek &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UI&lt;/em&gt; to żeby zadanie mogło aktualizować &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UI&lt;/em&gt; musi używać tego wątku. Aby to osiągnąć używa się metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StartNew&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContinueWith &lt;/strong&gt;pobierającej jako parametr obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskScheduler&lt;/strong&gt; i wstawia się jako wartość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TaskScheduler.FromCurrentSynchronizationContext()&lt;/strong&gt;. &lt;br /&gt;Przykład użycia metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;UpdateLabel&lt;/strong&gt; jako zadania w aplikacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Windows Forms&lt;/em&gt; w wątku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;UI&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Task&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.Factory&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.StartNew&lt;/span&gt;(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;UpdateLabel&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CancellationToken&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.None&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;TaskCreationOptions&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.None&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;TaskScheduler&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;.FromCurrentSynchronizationContext&lt;/span&gt;()&lt;br /&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie klasy Parallel&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; jest abstrakcją reprezentującą operacje asynchroniczne wykonywane przez wątki. Mimo, że są lżejsze niż wątki, czasami po prostu trzeba lepszej abstrakcji przy pracy wielozadaniowej. Dlatego &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; stworzył klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Parallel&lt;/strong&gt;. Jest ona częścią przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading.Tasks&lt;/strong&gt;. Klasa ta posiada trzy metody statyczne opisane poniżej:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;For&lt;/strong&gt; - Metoda podobna do pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;for&lt;/strong&gt; lecz wykonywana równolegle. Posiada 12 przeciążeń akceptujących jako parametry min &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParallelOptions&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParallelLoopState&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ForEach&lt;/strong&gt; - Podobna do pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;foreach&lt;/strong&gt; ale wykonywana równolegle. Posiada 20 przeciążeń z parametrami podobnymi do metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;For&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Invoke&lt;/strong&gt; - Metoda ta będzie próbować uruchomić dostarczonych akcji równolegle. Posiada dwa przeciążenia. Oba przyjmują delegatę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; do wykonania. Jedno przeciążenie przyjmuje parametr &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParallelOptions&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie trzy metody wspominają o możliwości uruchomienia równoległego ale żadna z nich tego nie gwarantuje. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParallelLoopState&lt;/strong&gt; jest używana jako parametr wejściowy dla niektórych metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;For&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ForEach&lt;/strong&gt;. Posiada ona dwie metody: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stop&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Break&lt;/strong&gt; których można użyć, aby przedwcześnie przerwać pętlę.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Parallel.For&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunParallelFor&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Here&lt;/span&gt; we call same &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt; several times &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; parallel.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Parallel&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;For&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;, i =&amp;gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;    });&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania aplikacji:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;The result is 2.06612397473398 &lt;br /&gt;We’re done in 10186ms!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tak jak w poprzednim przypadku wynik jest błędny. &lt;br /&gt;Poprawne użycie wymaga uzycia przeciążonej metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Parallel.For&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; ParallelLoopResult &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;For&lt;/span&gt;&amp;lt;TLocal&amp;gt;(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; fromInclusive,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; toExclusive,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Func&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;TLocal&lt;/span&gt;&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;localInit&lt;/span&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Func&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;int&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ParallelLoopState&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;TLocal&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;TLocal&lt;/span&gt;&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;body&lt;/span&gt;,&lt;/span&gt;&lt;br /&gt;    Action&amp;lt;TLocal&amp;gt; localFinally&lt;br /&gt;)&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunParallelForCorrected&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Here&lt;/span&gt; we call same &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt; several times.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;; i++)&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Parallel&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;For&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;NUMBER_OF_ITERATIONS&lt;/span&gt;,&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Func&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;TLocal&lt;/span&gt;&amp;gt; localInit,&lt;br /&gt;        () =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d,&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Func&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ParallelLoopState&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;TLocal&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;TLocal&lt;/span&gt;&amp;gt; body,&lt;br /&gt;        (i, state, interimResult) =&amp;gt; interimResult + &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;(),&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Final&lt;/span&gt; step after the calculations&lt;br /&gt;        // we add the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; to the final &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;TLocal&lt;/span&gt;&amp;gt; localFinally&lt;br /&gt;        (lastInterimResult) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += lastInterimResult&lt;br /&gt;    );&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania aplikacji:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;The result is 22.0386557304958 &lt;br /&gt;We’re done in 10370ms!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Praca z kontynuacjami&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W niektórych sytuacjach nie można przekształcić wszystkiego w zadania bez łamania algorytmu naszej aplikacji. Musimy dbać o zależności wynikające z algorytmu. Jeżeli z zależności w algorytmie wynika, że nie można wykonać kroku 3 przed zakończeniem kroku 1 i kroku 2 to można użyć pewnych mechanizmów kontynuacji dostępnych w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TPL&lt;/strong&gt;. Załóżmy, że mamy w aplikacji trzy metody nazwane &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step1&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step2&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step3&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;        Step1();&lt;br /&gt;        Step2();&lt;br /&gt;        Step3();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Step1&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Step1"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Step2&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Step2"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Step3&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Step3"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zaimplementujmy funkcjonalność opartą o zadania dla różnych scenariuszy:&lt;/p&gt;
&lt;ol start="1" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli metody są niezależne od pozostałych to możemy użyć np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/span&gt;{&lt;br /&gt;    Parallel.Invoke(Step1, Step2, Step3);&lt;br /&gt;}&lt;/pre&gt;
&lt;ol start="2" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;step1&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step2&lt;/strong&gt; są niezależne lecz metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step3&lt;/strong&gt; może być wykonana po zakończeniu metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step1&lt;/strong&gt; np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;static void &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; args) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step1Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step2Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step2&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step3Task = step1Task.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ContinueWith&lt;/span&gt;( (previousTask) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step3&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WaitAll&lt;/span&gt;(step2Task, step3Task);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.WaitAll(step2Task, step3Task);&lt;/strong&gt; gwarantuje, że poczekamy na wyniki wszystkich kroków.&lt;/p&gt;
&lt;ol start="3" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;step1&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step2&lt;/strong&gt; są niezależne lecz metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step3&lt;/strong&gt; może być wykonana po zakończeniu metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step1&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step2&lt;/strong&gt; np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;static void &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; args) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step1Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step2Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step2&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step3Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Factory&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ContinueWhenAll&lt;/span&gt;(&lt;br /&gt;        new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; { step1Task, step2Task },&lt;br /&gt;        (previousTasks) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step3&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;&lt;br /&gt;    );&lt;br /&gt;&lt;br /&gt;    step3Task.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Wait&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContinueWhenAll&lt;/strong&gt; pobiera jako pierwszy parametr tablicę zadań które mają być wykonane i delegatę do uruchomienia kiedy zadania się zakończa. Delegata pobiera jako parametr tablicę zadań na których wykonanie oczekuje.&lt;/p&gt;
&lt;ol start="4" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;step1&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step2&lt;/strong&gt; są niezależne lecz metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step3&lt;/strong&gt; może być wykonana po zakończeniu metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step1&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Step2&lt;/strong&gt; np:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;static void &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; args) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step1Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step2Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Run&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step2&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt; step3Task = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Factory&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ContinueWhenAny&lt;/span&gt;(&lt;br /&gt;        new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Task&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; { step1Task, step2Task },&lt;br /&gt;        (previousTask) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Step3&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;&lt;br /&gt;    );&lt;br /&gt;&lt;br /&gt;    step3Task.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Wait&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Asynchroniczne Aplikacje w C # 5.0&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C# 5.0&lt;/strong&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; wprowadził dwa nowe słowa kluczowe do języka: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;. &lt;br /&gt;Słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; możemy użyć aby oznaczyć metodę jako asynchroniczną i aby powiadomić kompilator, że metoda będzie miała co najmniej jedno wyrażenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;. Jeżeli kod nie posiada wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; to kompilator wygeneruje ostrzeżenie. &lt;br /&gt;Operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; stosuje się do zadania w metodzie asynchronicznej aby zawiesić wykonanie metody aż do momentu kiedy zawieszone zadanie zostanie wykonane. &lt;br /&gt;Wiele klas w bibliotece &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET Framework&lt;/strong&gt; używających &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt; zostało zmodyfikowanych poprzez dodanie do nich metod asynchronicznych wspierających wzorzec &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async/await&lt;/strong&gt;. &lt;br /&gt;Przykład metody synchronicznej symulującej odczyt z &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ReadDataFromIO&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// We are simulating an I/O by putting the current thread to sleep.&lt;/span&gt;&lt;br /&gt;    Thread.Sleep(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2000&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;d;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wariant asynchroniczny metody może wyglądać tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Task&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;&amp;gt; ReadDataFromIOAsync() {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Task&lt;/span&gt;.Run(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Func&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;&amp;gt;(ReadDataFromIO));&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby metoda była asynchroniczna musi zwracać obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; i posiadać sufiks &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Async&lt;/em&gt; w nazwie.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy metoda jest oznaczona modyfikatorem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; to musi zwracać jako wynik &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;void&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;. Jeżeli metoda synchroniczna zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;void&lt;/strong&gt; to można wybrać pomiędzy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;void&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt;. Jeżeli metoda nie jest obsługą zdarzenia to zaleca się aby zwracała &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; dzięki czemu jest nie tylko metodą asynchroniczną ale również można oczekiwać na jej wykonanie za pomocą słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;. Kiedy metoda synchroniczna zwraca wynik jakiegokolwiek typu to należy zwracać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; w metodzie asynchronicznej.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wracając do aplikacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;WPF&lt;/em&gt; z poprzedniej sekcji zamieńmy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadDataFromIO&lt;/strong&gt; na jej wersję asynchroniczną:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;partial&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MainWindow&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Window&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MainWindow&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        InitializeComponent();&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;btnRun_Click&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;        lblResult.Content = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; ReadDataFromIOAsync();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;kod napisany w ten sposób powoduje, że aplikacja nie zamarza i zwraca ten sam rezultat. Przeanalizujmy jak to działa:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodajemy słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; aby oznaczyć metodę jako asynchroniczną. Zwracany typ metody nie ulega zmianie ponieważ musimy użyć sygnatury delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventHandler&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zastępujemy wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadDataFromIO&lt;/strong&gt; poprzez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await ReadDataFromIOAsync&lt;/strong&gt;. Jest to równe wyrażeniu:&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Task&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt;&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;task&lt;/span&gt; = ReadDataFromIOAsync();&lt;br /&gt;lblResult.Content = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;task&lt;/span&gt;.Result;&lt;/pre&gt;
&lt;ol start="3" style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy wywołujemy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadDataFromIOAsync&lt;/strong&gt; to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; wykonuje kod do momentu kiedy zostaje on zablokowany przez operację &lt;em style="box-sizing: border-box; outline: none !important;"&gt;I/O&lt;/em&gt;. W tym momencie stan metody zostaje zapisany, otoczony w zadanie i zwrócony do metody wywołującej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda wywołująca kontynuuje wykonanie do momentu kiedy potrzebuje wyniku. W tym wypadku wynik otrzymuje od razu ale możliwe jest, że zapisuje zadanie, wykonuje więcej pracy synchronicznej i dopiero później wywołuje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; blokując metodę wywołującą.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Rozpatrzmy przykład w którym wywołujemy metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/em&gt; kilkukrotnie z wnętrza kodu a nie z obsługi zdarzeń i aktualizujemy w ten sposób kilka etykiet np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;partial&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MainWindow&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Window&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MainWindow&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        InitializeComponent();&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;btnRun_Click&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e&lt;/span&gt;) &lt;/span&gt;{&lt;br /&gt;        GetData();&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetData&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;        lblResult.Content = ReadDataFromIO();&lt;br /&gt;        lblResult2.Content = ReadDataFromIO();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby zmienić kod w asynchroniczny musimy najpierw zmienić metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;GetData&lt;/em&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt; Task &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetDataAsync&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;    lblResult.Content = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; ReadDataFromIOAsync();&lt;br /&gt;    lblResult2.Content = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; ReadDataFromIOAsync();&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dodaliśmy modyfikator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; do metody i zmieniliśmy jej nazwę poprzez dodanie sufiksu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assync&lt;/strong&gt;. Zwracany typ został zmieniony do typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task&lt;/strong&gt; i użyliśmy asynchronicznej wersji metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIOAsync&lt;/em&gt; wraz ze słowek kluczowym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt;. &lt;br /&gt;Kiedy uruchomimy aplikacje to nie zostanie ona zamrożona po wciśnięciu guzika. po kilku sekundach otrzymamy pierwszy wynik a po kolejnych kilku następny. Dzieje się tak ponieważ blokujemy wywołującą metodę pierwszym wywołaniem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; i druga metoda czeka na jego ukończenie.&lt;br /&gt;Można to ulepszyć poprzez przepisanie metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;GetDataAsync&lt;/em&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt; Task &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetDataAsync&lt;/span&gt;() &lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; task1 = ReadDataFromIOAsync();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; task2 = ReadDataFromIOAsync();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Here we can do more processing&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// that doesn't need the data from the previous calls.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Now we need the data so we have to wait&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; Task.WhenAll(task1, task2);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Now we have data to show.&lt;/span&gt;&lt;br /&gt;    lblResult.Content = task1.Result;&lt;br /&gt;    lblResult2.Content = task2.Result;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Zaawansowane zagadnienia dotyczące wielowątkowości&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Programowanie wielowątkowe jest o wiele trudniejsze niż programowanie jednowątkowe z kilku przyczyn:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kilka wątków może próbować zaktualizować ten sam fragment danych w tym samym czasie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie zawsze gwarantuje jednakowe wyniki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jest trudne do śledzenia, rozumienia i odnajdywania błędów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jest trudne do testowania.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jednym z najczęściej spotykanych problemów jest tzw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;race condition&lt;/strong&gt;. Dzieje się to gdy co najmniej dwa wątki próbują zaktualizować ten sam zasób. Przeanalizujmy przykład takiej sytuacji. Załóżmy, że posiadamy zmienną nazwaną &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData&lt;/em&gt; i dwa wątki które próbują wykonać instrukcję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData++&lt;/em&gt;, która jest wykonywana przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt; w następujący sposób:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Odczyt &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData&lt;/em&gt; w rejestrze.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodanie 1 do wartości w rejestrze.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zapis nowej wartości z rejestru z powrotem do zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dlaczego jest to tak ważne? Ponieważ jeśli byłaby to tylko jedna instrukcja, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt; mógłby wykonać to raz i żaden błąd nie może być tutaj wprowadzony. nazywane jest to operacja atomową. Jeżeli mamy aplikację wielowątkową to obiekt harmonogramu może przerwać aktualny wątek w każdej chwili i może to doprowadzić do błędu, np:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData&lt;/em&gt; posiada wartość 0.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Pierwszy wątek uruchamia pierwszą instrukcję, odczytując wartość 0.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Drugi wątek uruchamia pierwszą instrukcję, odczytując wartość 0. Na maszynie z pojedynczym rdzeniem może to się wydarzyć kiedy harmonogram przerwie pierwszy wątek i uruchomi drugi. Na maszynach wielordzeniowych jest to normalna sytuacja ponieważ wątki mogą być uruchamiane na różnych rdzeniach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Pierwszy wątek inkrementuje wartość do 1.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Pierwszy wątek zapsuje wartość 1 do zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Drugi wątek inkrementuje wartość do 1. W tej sytuacji wartość powinna być równa 2 lecz wartość początkowa która jest zapisana dla wątku drugiego posiada jest “stara” i wynosi 0.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Drugi wątek zapisuje wartoś 1 do zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sharedData&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tak jak wyjaśniono taka sytuacja może zajść nawet w sytuacji kiedy aplikacja jest uruchamiana na maszynie z jednym rdzeniem lecz występuje dużo częściej na maszynach wielordzeniowych. Aby zapobiec takiej sytuacji należy upewnić się, że tylko jeden wątek ma dostęp do zmiennych współdzielonych w danym momencie czasu. &lt;br /&gt;Najlepszą metodą jest nie współdzielenie danych. Jeżeli musimy współdzielić dane to sprawmy aby były tylko do odczytu. Czasami jest to niemożliwe ze względu na rozmiar danych. Jeżeli tak jest to należy wyizolować dane i mieć pewność, że są używane w kontrolowany sposób. Jeżeli nie jest to możliwe to należy użyć mechanizmów synchronizacji danych. Podsumowując, kolejność rozważania na temat danych współdzielonych jest następująca:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie współdziel.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Spraw aby dane były tylko do odczytu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Izoluj dane w mniejszych modułach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użyj mechanizmów synchronizacji danych.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Synchronizacja zasobów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; zapewnia kilka klas pozwalających na synchronizację zasobów. Istnieją klasy umożliwiające sygnalizację, wzajemne wykluczenie, anulowanie i klasy obsługujące kolekcja współbieżne.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Sygnalizacja jest używana jako mechanizm komunikacji pomiędzy watkami. W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; istnieją dwa rodzaje sygnalizacji: zdarzenia synchronizacji i bariery.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Zdarzenia synchronizacji&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zdarzenia synchronizacji są obiektami które mogą się znajdować w dwóch stanach: sygnalizowany i niesygnalizowany. Jeżeli wątek potrzebuje aby coś było wykonane w innym wątku to może użyć zdarzenia sygnalizacji i badać stan zdarzenia jako mechanizm komunikacji. jeżeli jest w stanie sygnalizowanym to znaczy, że kontynuuje wykonywanie, jeżeli nie to znaczy, że blokuje wykonywanie, oczekując na zdarzenie, aż będzie sygnalizowane. Kiedy inne wątki zakończa swoją pracę, to sygnalizuje zdarzenie odblokowując oczekujące wątki. Zdarzenia synchronizacji są zaimplementowane w duch klasach: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventWaitHandle&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CountdownEvent&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventWaitHandle&lt;/strong&gt; reprezentuje zdarzenie synchronizacji i jest zdefiniowana w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading&lt;/strong&gt;. najczęściej wykorzystywane metody tej klasy to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventWaitHandle&lt;/strong&gt; - Konstruktor z czterema przeciążeniami. Trzeba określić co najmniej czy zdarzenie powinno być sygnalizowane i czy zdarzenie powinno być resetowane manualnie czy automatycznie z użyciem enumeratora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventResetMode&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; - implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt;. Metoda oczyszczająca niepotrzebne zasoby kiedy obiekt nie jest już potrzebny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reset&lt;/strong&gt; - ustawia stan zdarzenia na niesygnalizowany powodując blokowanie wątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Set&lt;/strong&gt; - ustawia stan zdarzenia na sygnalizowany. oczekujące wątki będą w stanie kontynuować. Jeżeli zdarzenie zostało utworzone jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AutoReset&lt;/strong&gt; to tylko jeden wątek może wywołać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitOne&lt;/strong&gt; bez bycia zablokowanym lub jeżeli istnieją blokowane wątki jako wynik działania metody&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitOne&lt;/strong&gt; to tylko jeden wątek zostanie odblokowany i zdarzenie będzie w stanie niesygnalizowanym do momętu wywołania metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Set&lt;/strong&gt;. Jeżeli zdarzenie było utworzone jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ManualReset&lt;/strong&gt; to zdarzenie będzie sygnalizowane do momentu uzycia na nim metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reset&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitOne&lt;/strong&gt; - Blokuje aktualny wątek jeżeli jest niesygnalizowany. jeżeli zdarzenie jest sygnalizowane i zostało utworzone jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AutoReset&lt;/strong&gt; to odblokowuje zdarzenie i resetuje je do stanu niesygnalizowanego.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użycia tych klas pokazujący jak zyskać pewność, że nie odczytujemy wyniku obliczeń przed ich zakończeniem. Oryginalna metoda wygląda tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunInThreadPool&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Create&lt;/span&gt; a work item to read &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; I/O&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ThreadPool&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;QueueUserWorkItem&lt;/span&gt;((x) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/span&gt;());&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Save&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; the calculation into another variable&lt;br /&gt;    double result2 = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Wait&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; the thread to finish&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;TODO&lt;/span&gt;: &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; will need a way to indicate&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;when&lt;/span&gt; the thread pool thread finished the execution&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Calculate&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;end&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += result2;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład rozwiązania za pomocą sygnalizacji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;RunInThreadPoolWithEvents&lt;/span&gt;() {&lt;br /&gt;    double &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;d;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;We&lt;/span&gt; use this event to signal &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;when&lt;/span&gt; the thread &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;is&lt;/span&gt; don executing.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;EventWaitHandle&lt;/span&gt; calculationDone =&lt;br /&gt;        new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;EventWaitHandle&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;false&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;EventResetMode&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ManualReset&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Create&lt;/span&gt; a work item to read &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;from&lt;/span&gt; I/O&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ThreadPool&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;QueueUserWorkItem&lt;/span&gt;((x) =&amp;gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ReadDataFromIO&lt;/span&gt;();&lt;br /&gt;        calculationDone.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Set&lt;/span&gt;();&lt;br /&gt;    });&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Save&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt; the calculation into another variable&lt;br /&gt;    double result2 = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;DoIntensiveCalculations&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Wait&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; the thread to finish&lt;br /&gt;    calculationDone.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WaitOne&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Calculate&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;end&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += result2;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Print&lt;/span&gt; the &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The result is {0}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod działa następująco:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzymy obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventWaitHandle&lt;/strong&gt; w stanie niesygnalizowanym.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dodajemy do kolejki nowe zadanie. po otrzymaniu pierwszego wyniku sygnalizujemy zdarzenie aby wskazać, że obliczenia są zakończone.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołujemy drugą metodę w wątku głównym.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Po otrzymaniu wyniku drugiej metody, czekamy na zakonczenie kalkulacji pierwszej metody poprzez oczekiwanie na to kiedy zdarzenie będzie w stanie sygnalizowanym.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;kiedy otrzymamy stan sygnalizowany wiemy, że posiadamy wynik więc możemy obliczyć wartość finalną i ją pokazać.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; posiada dwie klasy dziedziczące z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventWaitHandle&lt;/strong&gt;, są to: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AutoResetEvent&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ManualResetEvent&lt;/strong&gt;. obie posiadają tylko jeden konstruktor i nie posiadają żadnych metod ani właściwości. Ich konstruktor przyjmuje wartość logiczną oznaczającą czy zdarzenie jest w stanie sygnalizowanym czy nie.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CoundownEvent&lt;/strong&gt; jest zdefiniowana w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading&lt;/strong&gt; i została wprowadzona w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4&lt;/em&gt;. Scenariusz użycia klasy jest prosty: czekamy, aż zdefiniowana liczba wątków zostanie zakończona. najczęściej wykorzystywane metody i właściwości klasy&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CoundownEvent&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CountdownEvent&lt;/strong&gt; - konstruktor przyjmujący ilość oczekiwanych sygnałów zanim zmieni stan na sygnalizowany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddCount&lt;/strong&gt; - inkrementuje aktualną liczbę zdarzeń. Jeżeli zdarzenie jest ustawione to zgłasza wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidOperationException&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; - implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt;. Metoda oczyszczająca niepotrzebne zasoby kiedy obiekt nie jest już potrzebny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reset&lt;/strong&gt; - resetuje właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InitialCount&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Signal&lt;/strong&gt; - Rejestruje sygnał dekrementując właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CurrentCount&lt;/strong&gt; o określoną wartość.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryAddCount&lt;/strong&gt; - inkrementuje aktualną liczbę zdarzeń i nie zgłasza wyjątku jak metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddCount&lt;/strong&gt; lecz zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;false&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Wait&lt;/strong&gt; - Blokuje aktualny wątek dopóki zdarzenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CountdownEvent&lt;/strong&gt; jest ustawione.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CurrentCount&lt;/strong&gt; - właściwość tylko do odczytu zwracająca aktualna wartość wymaganych sygnałów brakujących do ustawienia zdarzenia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InitialCount&lt;/strong&gt; - właściwość tylko do odczytu, wartość początkowa wymaganych sygnałów brakujących do ustawienia zdarzenia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsSet&lt;/strong&gt; - właściwość tylko do odczytu, zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli zdarzenie jest ustawione.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitHandle&lt;/strong&gt; - właściwość tylko do odczytu zwracająca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitHandle&lt;/strong&gt; uzyty do oczekiwania na zdarzenie do ustawienia.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CoundownEvent&lt;/strong&gt; nie dziedziczy z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitHandle&lt;/strong&gt; jek większość klas synchronizacji dlatego posiada właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitHandle&lt;/strong&gt; zwracającą instancję używanego obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WaitHandle&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Bariery&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W scenariuszach wielowątkowych istnieją sytuacje w których wywołujemy kilka wątków i chcemy mieć pewność, że wszystkie dotrą do pewnego punktu, zanim będzie można kontynuować wykonywanie kodu. &lt;br /&gt;Przykładem takiego scenariusza możne być np sytuacja w której grupa przyjaciół decyduje się podróżować samochodem z punktu A do punktu C przez punk B. Wszyscy startują z punktu A i zatrzymują się w B; potem planują wystartować wspólnie jeszcze raz i spotkać sie w punkcie C. Niektórzy z nich mogą nawet zdecydować się, że nie chcą już podróżować i wrócić do domu. &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4&lt;/em&gt; wprowadził nową klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading.Barrier&lt;/strong&gt; która dotyczy dokładnie takich sytuacji. &lt;br /&gt;Najczęściej uzywane metody i właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Barrier&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Barrier&lt;/strong&gt; - konstruktor z dwoma przeciążeniami przyjmującymi jako parametr liczbę uczestników. Drugie przeciążenie pobiera dodatkowy parametr typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; który będzie uruchomiony po przybyciu wszystkich uczestników do bariery w jednej fazie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddParticipant&lt;/strong&gt; - wysyła informację do bariery o tym, że będzie jeszcze jeden uczestnik.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AddParticipants&lt;/strong&gt; - wysyła informację do bariery o tym, że będzie jeszcze kilku uczestników.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; - implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt;. Metoda oczyszczająca niepotrzebne zasoby kiedy obiekt nie jest już potrzebny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RemoveParticipant&lt;/strong&gt; - wysyła informację do bariery o tym, że będzie o jednego z uczestników mniej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RemoveParticipants&lt;/strong&gt; - wysyła informację do bariery o tym, że będzie o kilku uczestników mniej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SignalAndWait&lt;/strong&gt; - sześć przeciążeń. Sygnalizuje, że uczestnik dotarł do bariery i oczekuje na dotarcie innych uczestników. Przeciążenia służą do wywołania metody z tokenem anulującym i/lub limitem czasu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CurrentPhaseNumber&lt;/strong&gt; - właściwość tylko do odczytu zwracająca aktualną fazę bariery.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParticipantCount&lt;/strong&gt; - właściwość tylko do odczytu zwracająca całkowitą liczbę uczestników bariery.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ParticipantsRemaining&lt;/strong&gt; - właściwość tylko do odczytu zwracająca liczbę uczestników którzy jeszcze nie dotarli do bariery.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użycia klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Barrier&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/span&gt;{&lt;br /&gt;    var participants = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    Barrier barrier = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Barrier(participants + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// We add one for the main thread.&lt;/span&gt;&lt;br /&gt;        b =&amp;gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// This method is only called when all the paricipants arrived.&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0} paricipants are at rendez-vous point {1}."&lt;/span&gt;,&lt;br /&gt;                b.ParticipantCount -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// We substract the main thread.&lt;/span&gt;&lt;br /&gt;                b.CurrentPhaseNumber);&lt;br /&gt;        });&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; participants; i++) {&lt;br /&gt;        var localCopy = i;&lt;br /&gt;        Task.Run(() =&amp;gt; {&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} left point A!"&lt;/span&gt;, localCopy);&lt;br /&gt;            Thread.Sleep(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1000&lt;/span&gt; * localCopy + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;); &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do some "work"&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (localCopy % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;) {&lt;br /&gt;                Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} arrived at point B!"&lt;/span&gt;, localCopy);&lt;br /&gt;                barrier.SignalAndWait();&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt; {&lt;br /&gt;                Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} changed its mind and went back!"&lt;/span&gt;,&lt;br /&gt;                    localCopy);&lt;br /&gt;                barrier.RemoveParticipant();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;            Thread.Sleep(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1000&lt;/span&gt; * (participants - localCopy)); &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do some "more work"&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} arrived at point C!"&lt;/span&gt;, localCopy);&lt;br /&gt;            barrier.SignalAndWait();&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Main thread is waiting for {0} tasks!"&lt;/span&gt;,&lt;br /&gt;        barrier.ParticipantCount - &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;    barrier.SignalAndWait(); &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Waiting at the first phase&lt;/span&gt;&lt;br /&gt;    barrier.SignalAndWait(); &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Waiting at the second phase&lt;/span&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Main thread is done!"&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Main thread is waiting for 5 tasks! &lt;br /&gt;Task 4 left point A! &lt;br /&gt;Task 2 left point A! &lt;br /&gt;Task 0 left point A! &lt;br /&gt;Task 3 left point A! &lt;br /&gt;Task 1 left point A! &lt;br /&gt;Task 0 arrived at point B! &lt;br /&gt;Task 1 changed its mind and went back! &lt;br /&gt;Task 2 arrived at point B! &lt;br /&gt;Task 3 changed its mind and went back! &lt;br /&gt;Task 4 arrived at point B! &lt;br /&gt;3 paricipants are at rendez-vous point 0. &lt;br /&gt;Task 4 arrived at point C! &lt;br /&gt;Task 2 arrived at point C! &lt;br /&gt;Task 0 arrived at point C! &lt;br /&gt;3 paricipants are at rendez-vous point 1. &lt;br /&gt;Main thread is done!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie mechanizmów blokowania&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jednym ze sposobów radzenia sobie z udostępniania danych jest wzajemne wykluczanie (ang &lt;em style="box-sizing: border-box; outline: none !important;"&gt;mutual exclusion&lt;/em&gt;). Wzajemne wykluczanie zapewnia, że tylko jeden wątek ma dostęp do udostępnianego zasobu w danym czasie. jeżeli inny wątek próbuje dostać się do zasobu to zostaje zablokowany do czasu aż pierwszy z wątków nie zwolni dostępu do zasobu. Zamiast kontrolować wszystkie ścieżki kodu które kierują się do określonego regionu danych kontrolujemy regiony kodu które próbują otrzymać dostęp do części danych. Wzajemne wykluczanie jest zaimplementowane w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; na kilka sposobów: monitory, muteksy, semafory, blokady odczytu i zapisu oraz kilka implementacji nieblokujących.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Monitory&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Monitory są prymitywnymi synchronizatorami używanymi do synchronizacji dostępu do obiektów. Monitor jest zaimplementowany w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading.Monitor&lt;/strong&gt;. Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor&lt;/strong&gt; jest używana w połączeniu z typami referencyjnymi aby upewnić się, że tylko jeden wątek ma dostęp do obiektu w danej chwili. Klasa udostępnia tylko metody statyczne które pobierają jako pierwszy parametr obiekt który ma być blokowany. W każdym momencie najwyżej jeden wątek może zablokować obiekt za pomocą wywołania metody statycznej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.Enter&lt;/strong&gt;. Jeżeli inny wątek wywoła metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.Enter&lt;/strong&gt; zanim pierwszy wątek wywoła metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.Exit&lt;/strong&gt; to drugi wątek będzie blokowany do czasu aż pierwszy wywoła metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.Exit&lt;/strong&gt;. W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; wszystkie typy referencyjne posiadają pole które przechowuje referencję do wątku który nałożył blokadę na obiekt oraz listę wątków gotowych które czekają na nałożenie blokady oraz listę obiektów oczekujących na powiadomienie poprzez metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Pulse&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PulseAll&lt;/strong&gt;. &lt;br /&gt;Najczęściej wykorzystywane metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Enter&lt;/strong&gt; - zakłada wyłączną blokadę na obiekcie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exit&lt;/strong&gt; - zwalnia blokadę na obiekcie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsEntered&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli na obiekcie nałożona jest blokada. (Metoda została wprowadzona w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.5&lt;/em&gt;).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Pulse&lt;/strong&gt; - powiadamia wątek na liście oczekujących o zmianie stanu obiektu, w efekcie przenosząc wątek z listy oczekujących na listę gotowych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PulseAll&lt;/strong&gt; - powiadamia wszystkie wątki na liście oczekujących o zmianie stanu obiektu, w efekcie przenosząc wątki z listy oczekujących na listę gotowych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryEnter&lt;/strong&gt; - próbuje założyć wyłączną blokadę na obiekcie. metoda posiada sześć przeciążeń.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Wait&lt;/strong&gt; - zwalnia blokadę na obiekcie i blokuje aktualny wątek do czasu aż będzie potrzebował blokady. Aktualny wątek zostanie umieszczony na liście oczekujących i będzie czekał na wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Pulse&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PulseAll&lt;/strong&gt; aby mógł kontynuować wykonywanie.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Wait&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Pulse&lt;/strong&gt;i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PulseAll&lt;/strong&gt; mogą być wywoływane tylko przez wątek który jest właścicielem blokady. &lt;br /&gt;Prosty przykład użycia monitora:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e; font-style: italic;"&gt;syncObject&lt;/span&gt; =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;(&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Monitor&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Enter&lt;/span&gt;(syncObject);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Code updating some shared data&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Monitor&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Exit&lt;/span&gt;(syncObject);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod ten nie sprawdza czy w czasie wykonywania nie został zgłoszony wyjątek. Jeżeli wyjątek został zgłoszony to blokada nie zostanie zwolniona prowadząc do zakleszczenia. Aby rozwiązać ten problem można użyć bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e; font-style: italic;"&gt;syncObject&lt;/span&gt; =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;(&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Monitor&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Enter&lt;/span&gt;(syncObject);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Code updating some shared data&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;finally&lt;/span&gt; {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Monitor&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Exit&lt;/span&gt;(syncObject);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Język &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; posiada skrót do tego wyrażenia nazwany &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;lock&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e; font-style: italic;"&gt;syncObject&lt;/span&gt; =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;(&lt;/span&gt;);&lt;br /&gt;lock (syncObject) {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Code updating some shared data&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Alternatywy Lock-free&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Blokady są niebezpieczne i konsumują wiele zasobów. Czasem potrzebujemy wykonać proste operacje i chcemy być pewni, że są one atomowe. Aby rozwiązać tego typu problemy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt; oferuje klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Interlocked&lt;/strong&gt; zdefiniowaną w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Threading&lt;/strong&gt;. Klasa ta posiada jedynie metody statyczne, które reprezentują wyłącznie operacje atomowe co oznacza, że zostaną wykonane bez przerywania przez harmonogram. &lt;br /&gt;lista metod klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Interlocked&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Add&lt;/strong&gt; - dodaje dwie liczby 32-bitowe lub 64-bitowe i zastępuje pierwszą liczbę całkowitą z sumą, jako operacja atomowa.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CompareExchange&lt;/strong&gt; - porównuje pierwszy i trzeci parametr dla równości i jeżeli są równe, zastępuje pierwszy parametr wartością drugiego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Decrement&lt;/strong&gt; - dekrementuje wybraną zmienną i zapisuje wynik, jako operacja atomowa.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exchange&lt;/strong&gt; - ustawia obiekt do określonej wartości i zwraca odwołanie do oryginalnego obiektu, jako operacja atomowa.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Increment&lt;/strong&gt; - inkrementuje wybraną zmienną i zapisuje wynik, jako operacja atomowa.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - Ładuje wartość 64-bitową jako operacja atomowa i zwraca ją do wywołującego. Jest to konieczne tylko na platformach 32-bitowych.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Kolekcje współbieżne&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolekcje zaimplementowane w przestrzeniach nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Generic&lt;/strong&gt; nie zostały zaimplementowane jako thread-safe. Zostały zaimplementowane tak aby były szybkie. Przed &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.0&lt;/em&gt; jeżeli potrzebowaliśmy kolekcji współbieżnej to musieliśmy zaimplementować ją sami. Od &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.0&lt;/em&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; wprowadził kolekcje współbieżne. Wszystkie są zdefiniowane w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Collections.Concurrent&lt;/strong&gt;. Wszystkie kolekcje współbieżne, z wyjątkiem klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConcurrentDictionary&lt;/strong&gt;, implementują interfejs&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt;. Ten interfejs wprowadza następujące metody:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CopyTo&lt;/strong&gt; - kopiuje elementy obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt; do tablicy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Array&lt;/strong&gt;, startując od wybranej pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToArray&lt;/strong&gt; - zwraca nową tablicę zawierającą wszystkie elementy obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryAdd&lt;/strong&gt; - próbuje dodać obiekt do obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryTake&lt;/strong&gt; - próbuje usunąć i zwrócić obiekt z obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista klas implementujących interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BlockingCollection&lt;/strong&gt; - implementuje interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IProducerConsumerCollection&lt;/strong&gt;, zapewniając blokowanie i ograniczenia możliwości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConcurrentBag&lt;/strong&gt; - reprezentuje bezpieczną dla wątków kolekcję obiektów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConcurrentDictionary &amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt; - reprezentuje bezpieczną dla wątków wersję klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dictionary &amp;lt;TKey, TValue&amp;gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConcurrentQueue&lt;/strong&gt; - reprezentuje bezpieczną dla wątków wersję klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ConcurrentStack&lt;/strong&gt; - reprezentuje bezpieczną dla wątków wersję klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stack&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Praca z anulacjami (ang. Cancellations)&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przed &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.0&lt;/em&gt; każde anulowanie operacji było niebezpieczne. Aby anulować operację należało przerwać wątek lub porzucić operację. Pomimo, że to dziłało w większości przypadków to było źródłem wielu błędów. &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET 4.0&lt;/em&gt; wprowadził anulacje jako obywateli pierwszej klasy biblioteki &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET&lt;/em&gt;. Anulacje są odwołaniami kooperacyjnymi, co oznacza, że można wysłać żądanie unieważnienia do innego wątku, lub zadania, ale to ich wybór, aby uhonorować to żądanie. &lt;br /&gt;Możliwości anulacji są implementowane przy użyciu jednej klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt; i jednej struktury &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationToken&lt;/strong&gt; działających w następujący sposób:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeśli wątek chce mieć możliwość odwołania kolejnej operacji, tworzy obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kiedy odwoływalna asynchroniczna operacja startuje, wątek wywołujący podaje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationToken&lt;/strong&gt; uzyskany poprzez właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Token&lt;/strong&gt; obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt;. Odwoływalna asynchroniczna operacja oznacza, albo operację wspierającą anulowanie albo nowy watek lub, że zostanie utworzona poprzez aktualny wątek. To jest zwykle wyrażone w postaci jednej lub kilku metod przeciążonych akceptujących parametr &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationToken&lt;/strong&gt;. Wysyłając &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationToken&lt;/strong&gt; chcemy pozwolić operacji na zainicjowanie anulowania. Może to być wykonane jedynie przez obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeśli wątek rodzic chce, aby anulować trwające odwoływalne operacje, wywołuje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Cancel&lt;/strong&gt; na obiekcie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wszystkie bieżące operacje mogą używać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancelationToken&lt;/strong&gt; wysłany jako parametr, aby sprawdzić, czy odwołanie jest w toku i odpowiednio na nie reagować.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użyty w sekcji z barierami przerobiony w taki sposób aby anulował trasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 0px; margin: 0px 0px 1.1em; word-break: break-all; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/span&gt;{&lt;br /&gt;    var participants = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// We create a CancellationTokenSource to be able to initiate the cancellation&lt;/span&gt;&lt;br /&gt;    var tokenSource = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; CancellationTokenSource();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// We create a barrier object to use it for the rendez-vous points&lt;/span&gt;&lt;br /&gt;    var barrier = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Barrier(participants,&lt;br /&gt;        b =&amp;gt; {&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0} paricipants are at rendez-vous point {1}."&lt;/span&gt;,&lt;br /&gt;            b.ParticipantCount,&lt;br /&gt;            b.CurrentPhaseNumber);&lt;br /&gt;        });&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; participants; i++) {&lt;br /&gt;        var localCopy = i;&lt;br /&gt;        Task.Run(() =&amp;gt; {&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} left point A!"&lt;/span&gt;, localCopy);&lt;br /&gt;            Thread.Sleep(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1000&lt;/span&gt; * localCopy + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;); &lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do some "work"           &lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (localCopy % &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;) {&lt;br /&gt;                Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} arrived at point B!"&lt;/span&gt;, localCopy);&lt;br /&gt;                barrier.SignalAndWait(tokenSource.Token);&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt; {&lt;br /&gt;                Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} changed its mind and went back!"&lt;/span&gt;,&lt;br /&gt;                    localCopy);&lt;br /&gt;                barrier.RemoveParticipant();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;;&lt;br /&gt;            }           &lt;br /&gt;            Thread.Sleep(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1000&lt;/span&gt; * localCopy + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Task {0} arrived at point C!"&lt;/span&gt;, localCopy);&lt;br /&gt;            barrier.SignalAndWait(tokenSource.Token);&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Main thread is waiting for {0} tasks!"&lt;/span&gt;,&lt;br /&gt;        barrier.ParticipantsRemaining - &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;);&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Press enter to cancel!"&lt;/span&gt;);&lt;br /&gt;    Console.ReadLine();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;(barrier.CurrentPhaseNumber &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;){&lt;br /&gt;        tokenSource.Cancel();&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"We canceled the operation!"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Too late to cancel!"&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;    Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Main thread is done!"&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod startuje od utworzenia obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Barrier&lt;/strong&gt;. Liczba uczestników bariery jest taka sama jak liczba wszystkich uczestników ponieważ chcemy użyć głównego wątku do anulowania. &lt;br /&gt;Następnie w kodzie dla każdego uczestnika tworzone jest zadanie. Tak jak poprzednio, każde zadanie które zmieniło zdanie zostaje usunięte z bariery. &lt;br /&gt;Następnie kod wywołuje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SignalAndWait&lt;/strong&gt;, co wysyła token anulowania z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt;. &lt;br /&gt;Główny wątek wywołuje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Console.ReadLine&lt;/strong&gt; czekając na komendę użytkownika. Kiedy użytkownik naciśnie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Enter&lt;/em&gt;, kod sprawdza czy wszyscy dotarli do celu. Kiedy się tego dowie poprzez zapytanie o wartość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CurrentPhaseNumber&lt;/strong&gt; obiektu bariery. Jeżeli wartość wynosi 2 to oznacza, że wszyscy przeszli przez dwie fazy, więc nie trzeba anulować operacji. &lt;br /&gt;Finalnie, kod wywołuje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;tokenSource.Cancel&lt;/strong&gt;, co wysyła sygnał anulowania do wszystkich obiektów czekających w obiekcie bariery, co odblokowuje je i anuluje pozostałą część operacji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wątki (ang. Threads)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wątek tworzymy poprzez wysłanie do konstruktora delegaty która będzie główną metodą wątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wątek startujemy poprzez bezpośrednie wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Start&lt;/strong&gt; na jego obiekcie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby użyć puli wątków wywołujemy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThreadPool.QueueUserWorkItem&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ThreadPool.RegisterWaitForSingleObject&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Zadania (ang. Tasks)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zadanie tworzymy poprzez wysłanie do konstruktora delegaty która będzie główną metodą zadania. Zadanie startujemy poprzez bezpośrednie wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Start&lt;/strong&gt; na jego obiekcie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołanie metody statycznej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.Run&lt;/strong&gt; z delegatą jako parametrem która będzie główną metodą zadania, tworzymy zadanie które jest startowane automatycznie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywołanie metody statycznej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Task.Factory.StartNew&lt;/strong&gt; z delegatą jako parametrem która będzie główną metodą zadania, tworzymy zadanie które jest startowane automatycznie.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Blokady (ang. Locks)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Używamy metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.Enter&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.TryEnter&lt;/strong&gt; aby założyć blokadę. Używamy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Monitor.Exit&lt;/strong&gt; aby zwolnić blokadę.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;W języku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C#&lt;/strong&gt; można użyć wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;lock&lt;/strong&gt;, które jest skrótem dla utworzenia i zwolnienia blokady w bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-finally&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Anulowanie (ang. Cancellations)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Używamy obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt; do kontrolowania operacji anulowalnych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Używamy obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationToken&lt;/strong&gt; uzyskanego z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt; za pomocą właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Token&lt;/strong&gt; aby wystartować operację anulowalną.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby anulować operację wywołujemy metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Cancel&lt;/strong&gt; obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CancellationTokenSource&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;async/await&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Są to dwa nowe słowa kluczowe wprowadzone w języku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C# 5.0&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; oznacza metodę jako asynchroniczną, mówiąc kompilatorowi, że metoda posiada instrukcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; w swoim ciele. Jeżeli w ciele metody nie ma instrukcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; to kompilator zwróci ostrzeżenie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; blokuje wykonanie aktualnej metody, czekając na wykonanie oczekiwanej operacji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;BackgroundWorker&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonuje długotrwałe operacje które trzeba wykonać jako zdarzenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DoWork&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Operację startujemy poprzez wywołanie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerAsync&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby dowiedzieć się kiedy długotrwała operacja została wykonana należy subskrybować zdarzenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RunWorkerCompleted&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Aby dowiedzieć się o postępie operacji należy subskrybować zdarzenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ProgressChanged&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Kontynuacje zadań (ang. Task continuation)&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kontynuuje zadanie za pomocą metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ContinueWith&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WhenAll&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WhenAny&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 07 Jan 2016 17:03:07 Z</pubDate>
      <a10:updated>2016-01-07T17:03:07Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1123</guid>
      <link>http://smsoft.pl/blog/v-delegaty-zdarzenia-i-wyjatki/</link>
      <title>V. Delegaty, zdarzenia i wyjątki</title>
      <description>&lt;p&gt;&lt;span style="color: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 32px;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzenie i implementacja zdarzeń i wywołań zwrotnych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie wyrażeń lambda.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie metod anonimowych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Implementacja obsługi wyjątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Blok try-catch-finally.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyrzucanie wyjątków.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Praca z delegatami&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod pokazuje jak tworzymy delegat:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;[accessibility]&lt;/span&gt; delegate returnType &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;DelegateName&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;[parameters]&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Elementy tworzenia delegat:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;accessibility&lt;/em&gt; - modyfikator dostępu do delegat np. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;private&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;public&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;delegate&lt;/strong&gt; - wymagane słowo kluczowe.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;returnType&lt;/em&gt; - typ danych zwracany przez metody tego delegaty np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;DelegateName&lt;/em&gt; - nazwa typu delegaty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;parameters&lt;/em&gt; - lista parametrów które metody tego typu delegaty powinny przyjmować na wejściu. &lt;br /&gt;Przykładowy delegat:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;float&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;FunctionDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;float&lt;/span&gt; x)&lt;/span&gt;&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ten typ reprezentuje metody które przyjmują liczbę typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;float&lt;/em&gt; jako parametr i zwracają typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/em&gt; jako wynik. &lt;br /&gt;Po zdefiniowaniu typu delegaty można utworzyć zmienną tego typu. Poniższy kod deklaruje zmienną &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TheFunction&lt;/em&gt; typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FunctionDelegate&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; FunctionDelegate TheFunction;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Później można ustawić zmienną na metodę która ma odpowiednie parametry i zwraca odpowiedni typ. Poniższy kod definiuje metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Function1&lt;/em&gt; i ustawia zmienną &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TheFunction&lt;/em&gt; na zadeklarowaną metodę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// y = 12 * Sin(3 * x) / (1 + |x|)&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;float&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Function1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;float&lt;/span&gt; x)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;)(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;12&lt;/span&gt; * Math.Sin(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt; * x) / (&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt; + Math.Abs(x)));&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Initialize TheFunction.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_Load&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;TheFunction = Function1;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Po inicjalizacji zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TheFunction&lt;/em&gt; program może użyć jej jakby to była sama metoda. Przykładowo poniższy kod ustawia zmienną &lt;em style="box-sizing: border-box; outline: none !important;"&gt;y&lt;/em&gt; równą wartości zwracanej przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TheFunction&lt;/em&gt; z parametrem o wartości 1.23.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; y = TheFunction(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1.23f&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W tym momencie nie wiadomo do jakiej metody odnosi się zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;TheFunction&lt;/em&gt;. Zmienna może odnosić się do metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Function1&lt;/em&gt; lub innej metody która posiada sygnaturę pasującą do typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FunctionDelegate&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zaleca się aby delegaty przechowywać w zmiennych. Delegaty można przechowywać jak każdy inny typ wartości w strukturze, tablicy czy liście. Przykładowo poniższy kod tworzy listę z która może zawierać referencje do metod które pasują do typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FunctionDelegate&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;FunctionDelegate&amp;gt; functions = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;List&lt;/span&gt;&amp;lt;FunctionDelegate&amp;gt;();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Szczegóły delegaty&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Użycie delegat jest podobne do użycia innych typów danych. Wartościami delegat są referencje do metod. Delegaty mają również zdefiniowane operacje takie jak dodawanie czy odejmowanie. Załóżmy, że metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Method1&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Method2&lt;/em&gt; nie pobierają żadnych parametrów i zwracają typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/em&gt; to poniższy kod jest poprawny:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Action&lt;/span&gt; del1 = Method1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Action&lt;/span&gt; del2 = Method2;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Action&lt;/span&gt; del3 = del1 + del2 + del1;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Delegata &lt;em style="box-sizing: border-box; outline: none !important;"&gt;del3&lt;/em&gt; zawiera serię zmiennych. Jeżeli ją wywołamy to program wykona po kolei &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Method1&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Method2&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Method1&lt;/em&gt;. &lt;br /&gt;Istnieje również kilka cech które są unikalne dla delegat.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metody statyczne i metody instancji&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli ustawimy zmienną delegaty do statycznej metody to jest jasne co stanie się po wywołaniu tej metody. Istnieje tylko jedna taka metoda współdzielona przez wszystkie instancje klasy która ją definiuje, więc to jest zawsze ta metoda która jest wywoływana. &lt;br /&gt;Jeżeli ustawimy wartość zmiennej delegaty do metody instancji to wynik może być bardziej zagmatwany. Kiedy wykonamy metodę przypisaną do zmiennej to wykonana zostanie metoda tej instancji klasy która została przypisana do zmiennej. &lt;br /&gt;Przykład kodu z metodą statyczną i metodą instancji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt;;&lt;br /&gt;    // A &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt; that returns a &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;.&lt;br /&gt;    public delegate &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetStringDelegate&lt;/span&gt;();&lt;br /&gt;    // A &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;.&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticName&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Static"&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Return&lt;/span&gt; this instance's &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt;.&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetName&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Variables&lt;/span&gt; to hold &lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetStringDelegates&lt;/span&gt;.&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetStringDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticMethod&lt;/span&gt;;&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetStringDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;//...&lt;br /&gt;private &lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Form1_Load&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; sender, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Make&lt;/span&gt; some &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Persons&lt;/span&gt;.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt; alice = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt;() { &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alice"&lt;/span&gt; };&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt; bob = new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt;() { &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt; };&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Make&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Alice&lt;/span&gt;'s &lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt; variable refer to her own &lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;.&lt;br /&gt;    alice.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt; = alice.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetName&lt;/span&gt;;&lt;br /&gt;    alice.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticMethod&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticName&lt;/span&gt;;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Make&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Bob&lt;/span&gt;'s &lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt; variable refer to &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Alice&lt;/span&gt;'s &lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;.&lt;br /&gt;    bob.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt; = alice.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;GetName&lt;/span&gt;;&lt;br /&gt;    bob.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticMethod&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticName&lt;/span&gt;;&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Demonstrate&lt;/span&gt; the methods.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alice's InstanceMethod returns: "&lt;/span&gt; + alice.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt;() +&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Environment&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NewLine&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob's InstanceMethod returns: "&lt;/span&gt; + bob.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;InstanceMethod&lt;/span&gt;() +&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Environment&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NewLine&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alice's StaticMethod returns: "&lt;/span&gt; + alice.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticMethod&lt;/span&gt;() +&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Environment&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NewLine&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob's StaticMethod returns: "&lt;/span&gt; + bob.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StaticMethod&lt;/span&gt;();&lt;br /&gt;    resultsTextBox.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Text&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;;&lt;br /&gt;    resultsTextBox.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Select&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Kowariancja i kontrawariancja&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kowariancja i kontrawariancja dają pewną elastyczność podczas przypisywania metod do zmiennych delegat. Przede wszystkim pozwalają traktować zwracany typ i parametry delegaty polimorficznie. &lt;br /&gt;Kowariancja pozwala metodzie zwracać wartości z podklas oczekiwanego przez delegatę wyniku. Przykładowo jeżeli klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; i delegata typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ReturnPersonDelegate&lt;/em&gt; reprezentuje metodę która zwraca obiekt typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; to można do zmiennej&lt;em style="box-sizing: border-box; outline: none !important;"&gt;ReturnPersonDelegate&lt;/em&gt; przypisać metodę która zwraca typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; ponieważ jest on podtypem klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;. &lt;br /&gt;Kontrawariancja pozwala metodom pobierać parametry które są typu klasy nadrzędnej do oczekiwanego typu. Przykładowo załużmy, że delegat typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;EmployeeParameterDelegate&lt;/em&gt; reprezentuje metodę która oczekuje obiektu klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; jako parametru to można do zmiennej typu&lt;em style="box-sizing: border-box; outline: none !important;"&gt;EmployeeParameterDelegate&lt;/em&gt; przypisać metodę która przyjmuje parametr typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;. &lt;br /&gt;Przykład kodu wykorzystującego kowariancję i kontrawariancję:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// A delegate that returns a Person.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt; Person &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ReturnPersonDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; ReturnPersonDelegate ReturnPersonMethod;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// A method that returns an Employee.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt; Employee &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ReturnEmployee&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Employee();&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// A delegate that takes an Employee as a parameter.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;EmployeeParameterDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(Employee employee)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; EmployeeParameterDelegate EmployeeParameterMethod;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// A method that takes a Person as a parameter.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;PersonParameter&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(Person person)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Initialize delegate variables.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_Load&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Use covariance to set ReturnPersonMethod = ReturnEmployee.&lt;/span&gt;&lt;br /&gt;    ReturnPersonMethod = ReturnEmployee;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Use contravariance to set EmployeeParameterMethod = PersonParameter.&lt;/span&gt;&lt;br /&gt;    EmployeeParameterMethod = PersonParameter;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wbudowane delegaty&lt;/h3&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Delegata Action&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Generyczna delegata &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; reprezentuje metodę zwracającą typ &lt;em style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/em&gt;. Różne wersje delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; pobieraja od 1 do 18 parametrów wejściowych. Poniższy kod pokazuje definicję delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; pobierającej dwa parametry wejściowe:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T1, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T2&amp;gt;(T1 arg1, T2 arg2)&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;in&lt;/strong&gt; z parametrami generycznymi oznacza, że parametry &lt;em style="box-sizing: border-box; outline: none !important;"&gt;T1&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;T2&lt;/em&gt; są kontrawariantami. &lt;br /&gt;jeżeli potrzebujemy zdefiniować delegat który pobiera mniej niż 18 parametrów wejściowych to możemy użyć &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; zamiast tworzyć swój własny typ. Przykładowe porównanie tworzenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Method 1.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;EmployeeParameterDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(Employee employee)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; EmployeeParameterDelegate EmployeeParameterMethod1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Method 2.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; Action&amp;lt;Employee&amp;gt; EmployeeParameterMethod2;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Delegata Func&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Generyczna delegata &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Func&lt;/strong&gt; reprezentuje metodę zwracającą wartość i pobiera od 1 do 18 parametrów wejściowych. Przykład delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Func&lt;/strong&gt; pobierającej dwa parametry wejściowe:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt; TResult Func&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T1, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T2, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;out&lt;/span&gt; TResult&amp;gt;(T1 arg1, T2 arg2)&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Trzy typy zdefiniowane przez generyczną delegatę to dwa typy parametrów wejściowych i typ zwracany. Przykładowe porównanie tworzenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Method 1.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt; Person &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ReturnPersonDelegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; ReturnPersonDelegate ReturnPersonMethod1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Method 2.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; Func&amp;lt;Person&amp;gt; ReturnPersonMethod2;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Metody anonimowe&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody anonimowe to metody które nie posiadają nazwy. Zamiast tworzyć metodę w normalny sposób tworzy się delegatę która odnosi się do metody anonimowej. Składnia tworzenia delegaty z metodą anonimową:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;[parameters]&lt;/span&gt;) { &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;code&lt;/span&gt;... }&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład metody anonimowej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; Func&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;&amp;gt; Function = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; x) { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x * x; };&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Nie można wywołać takiej metody po nazwie ale można użyć zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Function&lt;/em&gt; aby wywołać metodę. &lt;br /&gt;Zwykle używa się metod anonimowych kiedy program kiedy program potrzebuje relatywnie prostego fragmentu kodu wywoływanego w jednym miejscu. &lt;br /&gt;Dwa inne miejsca gdzie często wykorzystuje się metody anonimowe to definiowanie prostej obsługi zdarzeń i wykonywanie prostych zadań w osobnych wątkach. &lt;br /&gt;Poniższy kod dodaje obsługę zdarzenia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Paint&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_Load&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Paint += &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; obj, PaintEventArgs args)&lt;br /&gt;    {&lt;br /&gt;        args.Graphics.DrawEllipse(Pens.Red, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;200&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;100&lt;/span&gt;);&lt;br /&gt;    };&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod wykonuje metodę anonimową w osobnym wątku:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;void&lt;/span&gt; Form1_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    System&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Threading&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Thread&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;thread&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;=&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;new&lt;/span&gt; System&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Threading&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Thread&lt;/span&gt;(&lt;br /&gt;        delegate() { MessageBox&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hello World"&lt;/span&gt;); }&lt;br /&gt;    );&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;thread&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;.&lt;/span&gt;Start();&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wyrażenia Lambda&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody anonimowe pozwalaja na tworzenie krótkich metod wykonywanych tylko w jednym miejscu. Wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;lambda&lt;/strong&gt; są skróconą notacją tworzącą metody anonimowe. &lt;br /&gt;Wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;lambda&lt;/strong&gt; mogą być zapisywane w kilku formatach i kilku wariantach:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Expression Lambdas&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Składnia wyrażenia lambda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; expression;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;expression&lt;/em&gt; w kodzie jest pojedynczą deklaracją języka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; która powinna być wykonana przez delegatę. Fakt, że to wyrażenie lambda posiada pojedyncze wyrażenie po prawej stronie sprawia, że jest to wyrażenie lambda. &lt;br /&gt;Pusty nawias reprezentuje pustą listę parametrów metody anonimowej. Znaki &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;=&amp;gt;&lt;/strong&gt; oznaczają, że jest to deklaracja lambda. &lt;br /&gt;Przykład użycia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Action note = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt; =&amp;gt;&lt;/span&gt; MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hi"&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użycia z parametrami:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; note = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;) =&amp;gt; MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy wyrażenie lambda posiada jeden parametr to można ominąć nawias np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; note = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt; =&amp;gt; MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zwykle &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt; potrafi wywnioskować typy danych parametrów wyrażenia lambda. Jeżeli nie lub jeżeli chcemy zapisać kod bardziej jawnie to można zawrzeć typ danych parametrów np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; note = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;) =&amp;gt; MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład z czterema parametrami wejściowymi:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;, MessageBoxButtons, MessageBoxIcon&amp;gt; note;&lt;br /&gt;note = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;, caption, buttons, icon) =&amp;gt;&lt;br /&gt;    MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;, caption, buttons, icon);&lt;br /&gt;note(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Invalid input"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Alert"&lt;/span&gt;, MessageBoxButtons.OK,&lt;br /&gt;    MessageBoxIcon.Asterisk);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie lambda może również zwracać wartość np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Func&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt;&amp;gt; square = (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt; x) =&amp;gt; x * x;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt; y = square(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;13&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Statement Lambdas&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Deklaracja lambda różni się tym, że jej kod zawarty jest w nawiasie klamrowym oraz musi posiadać deklarację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;return&lt;/strong&gt; zwracającą jakiś wynik. Pozwala to na zapis bardziej skomplikowanych wyrażeń składających się z więcej niż jednego wyrażenia. &lt;br /&gt;Przykład deklaracji lambda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;TheFunction = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; x) =&amp;gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; A = -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0.0003f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; B = -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0.0024f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; C = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0.02f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; D = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0.09f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; E = -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0.5f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; F = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0.3f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;const&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; G = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3f&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; (((((A * x + B) * x + C) * x + D) * x + E) * x + F) * x + G;&lt;br /&gt;    };&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Async Lambdas&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Asynchroniczne wyrażenia lambda pozwalają na użycie słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;async&lt;/strong&gt; sprawiającego, że metoda może być wykonywana asynchronicznie. Można wtedy użyć słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;await&lt;/strong&gt; aby fragment kodu wywołał asynchroniczną metodę i poczekał na zwracaną wartość. Przykład kodu wykorzystującego asynchroniczne wyrażenie lambda:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The number of times we have run DoSomethingAsync.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Trials = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Create an event handler for the button.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1_Load&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    runAsyncButton.Click += &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;async&lt;/span&gt; (button, buttonArgs) =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; trial = ++Trials;&lt;br /&gt;            statusLabel.Text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Running trial "&lt;/span&gt; + trial.ToString() + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"..."&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; DoSomethingAsync();&lt;br /&gt;            statusLabel.Text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Done with trial "&lt;/span&gt; + trial.ToString();&lt;br /&gt;        };&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do something time consuming.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;async&lt;/span&gt; Task &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DoSomethingAsync&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// In this example, just waste some time.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;await&lt;/span&gt; Task.Delay(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3000&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Praca ze zdarzeniami&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zdarzenia pozwalają obiektom na komunikowanie programowi, że coś ciekawego zaszło. Przykładowo obiekt skrzynki email może wywołać zdarzenie aby powiedzieć programowi, że otrzymał nową wiadomość, guzik może wywołać zdarzenie mówiące programowi, że użytkownik nacisnął reprezentację graficzną guzika na ekranie. Obiekt, który wywołuje zdarzenie nazywa wydawca tego zdarzenia (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;event’s publisher&lt;/em&gt;). Klasa która przechwytuje zdarzenia nazywana jest subskrybentem (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;subscriber&lt;/em&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Publikowanie zdarzeń&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zanim obiekt zgłosi zdarzenie, musi najpierw je zadeklarować aby subskrybenci wiedzieli jakie zdarzenie jest zgłaszane i jakie parametry zawiera. Składnia deklaracji zdarzenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;accessibility &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt; EventName;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowo klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;BankAccount&lt;/em&gt; może używać poniższego kodu do definiowania zdarzenia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Overdrawn&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OverdrawnEventHandler&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; OverdrawnEventHandler Overdrawn;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pierwsza linijka deklaruje delegatę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OverdrawnEventHandler&lt;/em&gt;, która reprezentuje metodę nie pobierającą żadnych parametrów wejściowych i zwracającą &lt;em style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/em&gt;. &lt;br /&gt;Druga linijka deklaruje zdarzenie o nazwie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Overdrawn&lt;/em&gt; typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OverdrawnEventHandler&lt;/em&gt;. Oznacza to, że subskrybenci muszą użyć metod pasujących do delegaty &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OverdrawnEventHandler&lt;/em&gt; aby obsłużyć to zdarzenie. &lt;br /&gt;Później obiekt &lt;em style="box-sizing: border-box; outline: none !important;"&gt;BankAccount&lt;/em&gt; może zgłosić to zdarzenie w razie potrzeby. Przykład klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;BankAccount&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;BankAccount&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OverdrawnEventHandler&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; OverdrawnEventHandler Overdrawn;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The account balance.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt; Balance { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Add money to the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Credit&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; amount)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Balance += amount;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove money from the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Debit&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; amount)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// See if there is this much money in the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Balance &amp;gt;= amount)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove the money.&lt;/span&gt;&lt;br /&gt;            Balance -= amount;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Raise the Overdrawn event.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Overdrawn != &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;) Overdrawn();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Predefiniowane typy zdarzeń&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zdarzenie zdefiniowane powyżej, które nie pobiera parametrów i nic nie zwraca można uprościć za pomocą predefiniowanej delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; Action Overdrawn;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Najlepsze praktyki używania zdarzeń&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; zaleca aby wszystkie zdarzenia posiadały dwa parametry: obiekt zgłaszający zdarzenie i obiekt z argumentami które są wymagane do obsługi zdarzenia. Drugi obiekt powinien dziedziczyć z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventArgs&lt;/strong&gt;. &lt;br /&gt;Przykładowo obiekt klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;BankAccount&lt;/em&gt; opisany w poprzedniej sekcji powinien być pierwszym argumentem zdarzenia tak aby można było stwierdzić które konto zgłosiło zdarzenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Overdrawn&lt;/em&gt;. &lt;br /&gt;Fakt, że zdarzenie zostało zgłoszone mówi nam o tym, że konto nie posiada wystarczającej ilości środków ale nie mówi nam jak duży jest debet. Można zmodyfikować program tak aby jako drugi parametr przesyłał nam tę informację. &lt;br /&gt;Klasa z informacjami powinna dziedziczyć z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventArgs&lt;/strong&gt; i wg konwencji jej nazwa powinna składać się z nawy zdarzenia i przyrostka &lt;em style="box-sizing: border-box; outline: none !important;"&gt;EventArgs&lt;/em&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OverdrawnEventArgs&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;EventArgs&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt; CurrentBalance, DebitAmount;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OverdrawnEventArgs&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; currentBalance, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; debitAmount)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        CurrentBalance = currentBalance;&lt;br /&gt;        DebitAmount = debitAmount;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ obsługa zdarzenia wymaga teraz dwóch parametrów, to trzeba zmienić deklarację zdarzenia. Można stworzyć nową delegatę ale &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; posiada już predefiniowaną delegatę generyczną o nazwie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventHandler&lt;/strong&gt;. Deklaracja zdarzenia po zamianie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; EventHandler&amp;lt;OverdrawnEventArgs&amp;gt; Overdrawn;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Debit&lt;/em&gt; wywołująca nowy typ zdarzenia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove money from the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Debit&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; amount)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// See if there is this much money in the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Balance &amp;gt;= amount)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove the money.&lt;/span&gt;&lt;br /&gt;        Balance -= amount;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Raise the Overdrawn event.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Overdrawn != &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;)&lt;br /&gt;        Overdrawn(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; OverdrawnEventArgs(Balance, amount));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Dziedziczenie zdarzeń&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zdarzenie może być wywoływane jedynie z klasy która je deklaruje więc podklasy nie mogą zgłaszać zdarzeń zadeklarowanych w klasie bazowej. &lt;br /&gt;Rozwiązaniem zaproponowanym przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; jest dodanie do klasy bazowej metody chronionej która wywołuje zdarzenie. Klasa która dziedziczy może wywołać tę metodę aby zgłosić zdarzenie. Wg konwencji metody takie zaczynają się przedrostkiem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;On&lt;/strong&gt; i kończą nazwą zdarzenia np&lt;em style="box-sizing: border-box; outline: none !important;"&gt;OnOverdrawn&lt;/em&gt;. &lt;br /&gt;Wg wzorca obsługi metoda wywołująca zdarzenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Overdrawn&lt;/em&gt; klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;BankAccount&lt;/em&gt; powinna przenieść wywołanie zdarzenia do nowej metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OnOverdrawn&lt;/em&gt;, np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Raise the Overdrawn event.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;protected&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;virtual&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OnOverdrawn&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(OverdrawnEventArgs args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Overdrawn != &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;) Overdrawn(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;, args);&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove money from the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Debit&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; amount)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// See if there is this much money in the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Balance &amp;gt;= amount)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove the money.&lt;/span&gt;&lt;br /&gt;        Balance -= amount;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Raise the Overdrawn event.&lt;/span&gt;&lt;br /&gt;        OnOverdrawn(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; OverdrawnEventArgs(Balance, amount));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przypuśćmy, że chcemy dodać klasę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;MoneyMarketAccount&lt;/em&gt; dziedziczącą z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;BankAccount&lt;/em&gt;. Kiedy chcemy zgłosić zdarzenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Overdrawn&lt;/em&gt; to wywołujemy metodę rodzica &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OnOverdrawn&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MoneyMarketAccount&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;BankAccount&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DebitFee&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;decimal&lt;/span&gt; amount)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// See if there is this much money in the account.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (Balance &amp;gt;= amount)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remove the money.&lt;/span&gt;&lt;br /&gt;            Balance -= amount;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Raise the Overdrawn event.&lt;/span&gt;&lt;br /&gt;            OnOverdrawn(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; OverdrawnEventArgs(Balance, amount));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Subskrybowanie i anulowanie subskrypcji do zdarzeń&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby dodać subskrypcję zdarzenia można użyć kodu podobnego do tego poniżej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;processOrderButton.Click +&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt; processOrderButton_Click;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod ten dodaje metodę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;processOrderButton_Click&lt;/em&gt; jako obsługę zdarzenia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Click&lt;/em&gt; guzika &lt;em style="box-sizing: border-box; outline: none !important;"&gt;processOrderButton&lt;/em&gt;. &lt;br /&gt;Alternatywnie ten sam kod można napisać tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;processOrderButton.Click += &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; System.EventHandler(processOrderButton_Click);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowa pusta metoda obsługująca zdarzenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;processOrderButton_Click&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;processOrderButton_Click&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NotImplementedException();&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Anulowanie subskrypcji dokonywane jest za pomocą poniższego kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;processOrderButton.Click -&lt;/span&gt;=&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt; processOrderButton_Click;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli dokonamy subskrypcji zdarzenia więcej niż raz to obsługa tego zdarzenia będzie wywołana więcej niż raz. &lt;br /&gt;Za każdym razem jak anulujemy subskrypcję zdarzenia to usuwana jest jedna subskrypcja z listy subskrybentów. &lt;br /&gt;Jeżeli anulujemy subskrypcję obsługi zdarzenia które nie jest subskrybowane do zdarzenia to nic się nie wydarzy i nie będzie zgłoszony żaden błąd ani wyjątek. &lt;br /&gt;Subskrybowanie zdarzeń może się również odbyć z okna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Designer&lt;/em&gt; w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Obsługa wyjątków&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Bez względu na to, jak dobrze zaprojektujemy aplikację, pewne problemy są nieuniknione. Użytkownicy wpiszą nieprawidłowe wartości, niezbędne pliki zostaną usunięte a krytyczne połączenia sieciowe nie powiodą się. Aby uniknąć tego rodzaju problemów, program musi obsługiwać sprawdzanie błędów i obsługę wyjątków.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Sprawdzanie błędów i obsługa wyjątków&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Sprawdzanie błędów to proces przewidywania błędów, sprawdzając, czy będą występować, i pracy wokół nich. Na przykład, jeśli użytkownik musi wprowadzić liczbę całkowitą w polu tekstowym to w końcu ktoś wprowadzi wartość nienumeryczną. Jeśli program próbuje analizować wprowadzone wartości, jak gdyby były liczbą całkowitą, to ulegnie awarii. &lt;br /&gt;Zamiast awarii, program powinien walidować wprowadzany tekst aby sprawdzić czy ma on sens przed konwertowaniem jego wartości. Przykładowo metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;int.TryParse&lt;/em&gt; wykonuje obie te czynności. &lt;br /&gt;W przeciwieństwie do sprawdzania błędów, obsługa wyjątków jest procesem zabezpieczania aplikacji, gdy wystąpi nieoczekiwany błąd. Przykładowo kiedy program zacznie pobierać plik z sieci i w pewnym momencie utracone zostanie połączenie sieciowe. Nie ma możliwości aby program przewidział taki problem ponieważ sieć była dostępna kiedy program rozpoczynał pobieranie. &lt;br /&gt;Nawet jeśli sprawdzimy każdą wartość wprowadzoną przez użytkownika i sprawdzimy każdą możliwą sytuację, mogą pojawić się nieoczekiwane wyjątki. Pliki mogą zostać uszkodzone, połączenie sieciowe, które było obecne może zostać zerwane, w systemie może zabraknąć pamięci lub biblioteki, których używasz i nad którymi nie masz kontroli mogą wyrzucić wyjątek.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Blok try-catch-finally&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; pozwala programowi na przechwycenie niepożądanych błędów i ich obsługę. Zawiera on trzy sekcje: jeden blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt;, jeden lub wiele bloków &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; i blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt;. Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; jest wymagana i musi posiadać przynajmniej jedną sekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt;. &lt;br /&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; zawiera kod który może zgłosić wyjątek. W tej sekcji można zamieścić dowolną ilość deklaracji. Można również zagnieżdżać bloki &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;. Składnia sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    // Statements that might throw an exception.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;catch [(ExceptionType [variable])]&lt;br /&gt;{&lt;br /&gt;    //Statements to execute...&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; wystąpi wyjątek to program przegląda jego wszystkie sekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; w kolejności w jakiej zostały napisane w programie w poszukiwaniu obsługi typu wyjątku zgodnego ze zgłoszonym wyjątkiem. typ wyjątku jest zgodny jeżeli jest jednym z typów klasy typu wyjątku&lt;em style="box-sizing: border-box; outline: none !important;"&gt;ExceptionType&lt;/em&gt;. Przykładowo klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DivideByZeroException&lt;/em&gt; dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ArithmeticException&lt;/em&gt; która dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SystemException&lt;/em&gt; a at z kolei dziedzczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Exception&lt;/em&gt;. Jeżeli program wyrzuci wyjątek &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DivideByZeroException&lt;/em&gt; to obsłużyć go można w bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt;obsługującym którykolwiek z tych typów wyjątków. Każdy wyjątek dziedziczy z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt;, więc blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; z typem wyjątku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; przechwyci każdy zgłoszony wyjątek. &lt;br /&gt;Kiedy program znajdzie dopasowanie typu wyjątku w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; to wykona kod znajdujący się w odnalezionej sekcji i przeskoczy wszystkie pozostałe sekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt;. &lt;br /&gt;Ponieważ program przeszukuje sekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; w kolejności w jakiej zostały napisane w kodzie to należy tak pisać kod aby lista sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; rozpoczynała się od najbardziej szczegółowych wyjątków a kończyła się najbardziej ogólnymi. Przykładowo klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FormatException&lt;/em&gt; dziedziczy z&lt;em style="box-sizing: border-box; outline: none !important;"&gt;SystemException&lt;/em&gt; a ta dziedziczy z &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Exception&lt;/em&gt; więc blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch&lt;/strong&gt; powinien wyglądać tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Statements...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;catch&lt;/span&gt; (SystemException ex)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Statements...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;catch&lt;/span&gt; (FormatException ex)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Statements...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;catch&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Exception&lt;/span&gt; ex)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//Statements...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; nie podamy typu wyjątku to blok ten przechwyci wszystkie rodzaje wyjątków np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; quantity;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    quantity = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;.Parse(quantityTextBox.Text);&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;catch&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The quantity must be an integer."&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; zawiera typ wyjątku i zmienną to zmienna jest typu tego wyjątku i posiada informacje na temat zgłaszanego wyjątku. Wszystkie klasy dziedziczące z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; posiadają właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; która zawiera informację tekstową o zgłaszanym wyjątku. &lt;br /&gt;Jeżeli blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; zawiera typ wyjątku ale nie zawiera zmiennej to sekcja przechwyci wyjątek który pasuje do danego typu ale nie posiada szczegółowych informacji które byłyby zawarte w zmiennej. &lt;br /&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt; jest wykonywana po zakończeniu wykonywania sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt;. jest ona wykonywana zawsze, nawet jeżeli program opuści sekcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; z niżej wymienionych powodów:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; zakończyła się sukcesem i żadna sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; nie została wykonana.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; wyrzuciła wyjątek i sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; go obsłużyła.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; wyrzuciła wyjątek i żadna sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; go nie obsłużyła.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; użyła wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;return&lt;/strong&gt; służącego do wyjścia z metody.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; użyła wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;return&lt;/strong&gt; służącego do wyjścia z metody.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kod w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; wyrzucił wyjątek. &lt;br /&gt;Jedynie kod w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; jest chroniony przez blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;. jeżeli wyjątek zostanie zgłoszony w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; lub sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt; to nie zostanie obsłużony w tym bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;. Dlatego bloki &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; mogą być zagnieżdżone.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Użycie wyrażenia using&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; zachowuje się jak sekwencja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-finally&lt;/strong&gt; wywołująca metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; obiektu w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (Pen pen = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Pen(Color.Red, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;))&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Use the pen to draw...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jest ekwiwalentem kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Pen pen;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    pen = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Pen(Color.Red, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Use the pen to draw...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;finally&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (pen != &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;null&lt;/span&gt;) pen.Dispose();&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wyjątki nieobsłużone&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyjątki nieobsłużone występują wtedy gdy program wyrzuci wyjątek i nie jest on obsłużony w żadnym bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;. Może się to wydarzyć na dwa sposoby. Pierwszym jest gdy wyjątek zostaje wyrzucony we fragmencie kodu który nie znajduje się w bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;. Drugi przypadek jest wtedy gdy wyjątek zostaje wyrzucony w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; ale żadna sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; nie obsłuży tego wyjątku. &lt;br /&gt;Kiedy program napotka na nieobsłużony wyjątek to kontrola przechodzi do góry stosu wywołań do metody która wywołała kod który wywołał wyjątek. Jeżeli metoda ta znajduje się w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try&lt;/strong&gt; bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; to jego sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; spróbuje obsłużyć wyjątek. W przeciwnym wypadku kontrola przechodzi o poziom wyżej w stosie wywołań. Kontrola przechodzi wyżej aż znajdzie sekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; która obsłuży zgłoszony wyjątek. W tym wypadku kod zostaje wywoływany dalej od tego momentu w którym wyjątek został obsłużony. Jeżeli wyjątek nie zostanie obsłużony w żadnym bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; to program ulegnie awarii i pojawi się okno mówiące o awarii a w tym o wyjątku który został zgłoszony i stosie wywołań w programie prowadzącym do tego wyjątku. Okno posiada guziki umożliwiające zakończenie programu lub podjęcie próby kontynuacji działania programu. Przykład okna zgłaszającego nieobsłużony wyjątek. &lt;br /&gt;&lt;img longdesc="./1447503177351.png" style="box-sizing: border-box; outline: none !important; border: 0px; vertical-align: middle; max-width: 100%; height: auto;" alt="Alt text" /&gt;&lt;br /&gt;Aby chronić program przed możliwymi wyjątkami, należy cały kod zawrzeć w bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Powszechnie stosowane wyjątki&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; definiuje setki klas wyjątków reprezentujących różne błędy. Poniżej rysunek przedstawiający najczęściej wykorzystywane wyjątki zdefiniowane w przestrzeni nazw &lt;em style="box-sizing: border-box; outline: none !important;"&gt;System&lt;/em&gt;: &lt;br /&gt;&lt;img longdesc="./exceptions.png" style="box-sizing: border-box; outline: none !important; border: 0px; vertical-align: middle; max-width: 100%; height: auto;" alt="Alt text" /&gt;&lt;br /&gt;Użyteczne klasy wyjątków:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Exception&lt;/strong&gt; - Klasa bazowa wszystkich innych klas wyjątków. Reprezentuje wyjątki na wysokim poziomie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SystemException&lt;/strong&gt; - Klasa bazowa wyjątków zdefiniowanych w przestrzeni nazw &lt;em style="box-sizing: border-box; outline: none !important;"&gt;System&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArgumentException&lt;/strong&gt; - Jeden z argumentów metody jest niepoprawny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArgumentNullException&lt;/strong&gt; - Jeden z argumentów ma niedozwolona wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArgumentOutOfRangeException&lt;/strong&gt; - Argument jest poza dozwolonym zakresem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArithmeticException&lt;/strong&gt; - Błąd arytmetyczny lub błąd przy konwertowaniu lub rzutowaniu typów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DivideByZeroException&lt;/strong&gt; - Błąd dzielenia przez zero.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OverflowException&lt;/strong&gt; - Operacja arytmetyczna, konwersja lub rzutowanie wykonane w bloku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;checked&lt;/em&gt; zwraca błąd przepełnienia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NotFiniteNumberException&lt;/strong&gt; - Operacja zmiennoprzecinkowa zwraca błąd, że wynik jest nieskończonością lub NaN.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayTypeMismatchException&lt;/strong&gt; - Program próbuje wstawić zły typ do tablicy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FormatException&lt;/strong&gt; - Argument ma niepoprawny format.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IndexOutOfRangeException&lt;/strong&gt; - indeks tablicy z poza jej zakresu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidCastException&lt;/strong&gt; - Niepoprawne rzutowanie lub konwersja.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidOperationException&lt;/strong&gt; - Wywołanie metody jest nieprawidłowe dla obecnego stanu obiektu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.IOException&lt;/strong&gt; - Błąd wejścia/wyjścia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.DirectoryNotFoundException&lt;/strong&gt; - Cześć ścieżki nie została odnaleziona.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.DriveNotFoundException&lt;/strong&gt; - Dysk lub zasób sieciowy niedostępny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.EndOfStreamException&lt;/strong&gt; - Program próbował odczytać poza końcem strumienia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.FileLoadException&lt;/strong&gt; - Program próbował załadować plik który istnieje ale jest niedostępny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.FileNotFoundException&lt;/strong&gt; - Plik nie został odnaleziony.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IO.PathTooLongException&lt;/strong&gt; - Ścieżka lub nazwa pliku jest za długa.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NotImplementedException&lt;/strong&gt; - Funkcja niezaimplementowana.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NotSupportedException&lt;/strong&gt; - Program próbował wywołać metodę, która nie jest wspierana. Możesz wyrzucić ten wyjątek, aby wskazać metodę, która została usunięta w ostatnich wersjach biblioteki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NullReferenceException&lt;/strong&gt; - Program próbował dostać się do obiektu który ma wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OutOfMemoryException&lt;/strong&gt; - Za mało pamięci aby program mógł kontynuować.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;RankException&lt;/strong&gt; - Program wstawił do metody tablicę z niewłaściwą liczbą wymiarów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Security.SecurityException&lt;/strong&gt; - Błąd bezpieczeństwa.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Security.VerificationException&lt;/strong&gt; - Polityka bezpieczeństwa wymaga kodu by używał typów bezpiecznych, a kod nie może być zweryfikowany jako bezpiecznego typu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;UnauthorizedAccessException&lt;/strong&gt; - Dostęp zabroniony z powodu błędu wejścia/wyjścia lub bezpieczeństwa.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wyjątki SQL&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt; używa klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.SqlClient.SqlException&lt;/strong&gt; reprezentującej wszyskie błędy i wyjątki. Można użyć właściwości tej klasy aby dowiedzieć się co dokładnie się wydarzyło. Najbardziej użyteczne właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlException&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Class&lt;/strong&gt; - Numer od 0 do 25 oznaczający typ błędu. Błędy powyżej 20 są fatalne i oznaczają zamknięcie połączenia do bazy danych. Błędy poniżej 10 są klasy informacyjnej. Błędy z zakresu 11-16 mogą być naprawione przez użytkownika. Błąd 17 oznacza, że serwer korzysta z zasobów które nie są konfigurowalne i błąd może rozwiązać administrator. 18 to błąd niefatalny wewnątrz oprogramowania. 19 oznacza, że &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SQL Server&lt;/strong&gt; przekroczył limit zasobów. 20: problem w wyrażeniu wywołanym przez aktualny proces. 21: problem dotyczący wszystkich procesów bazy danych. 22: indeks lub tabela są uszkodzone. 23: baza danych jest uznana za uszkodzoną. 24: problem sprzętowy. 25: błąd systemowy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LineNumber&lt;/strong&gt; - numer błędnej linii w komendzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T-SQL&lt;/strong&gt; lub procedurze składowanej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; - Informacja opisująca problem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Number&lt;/strong&gt; - Numer błędu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Procedure&lt;/strong&gt; - Nazwa procedury wywołującej błąd. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.Common.DbException&lt;/strong&gt; jest klasa bazową klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlException&lt;/strong&gt; i jeszcze trzech innych klas reprezentujących błędy dla innych typów baz danych, są to:&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.Odbc.OdbcException&lt;/strong&gt; - Klasa błędów baz &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ODBC&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.OleDb.OleDbException&lt;/strong&gt; - Klasa błędów baz &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OleDb&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Data.OracleClient.OracleException&lt;/strong&gt; - Klasa błędów baz danych &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Oracle&lt;/em&gt;. &lt;br /&gt;Wszystkie te klasy zawierają właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;message&lt;/strong&gt; która zawiera informacja opisująca problem.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Overflow Exception&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Domyślnie program nie wyrzuca wyjątku jeżeli operacja arytmetyczna powoduje przepełnienie zakresu liczby całkowitej. Jeżeli operandy są całkowite lub dziesiętne to program obcina wartość wynikową. &lt;br /&gt;Aby program zwrócił wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OverflowException&lt;/strong&gt; należy użyć bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;checked&lt;/strong&gt; lub ustawić zaawansowaną opcję budowania. &lt;br /&gt;Program nie wyrzuca wyjątku również dla operacji zmiennoprzecinkowej która powoduje przepełnienie lub zwraca specialną wartość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NaN&lt;/strong&gt; (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;not a number&lt;/em&gt;). &lt;br /&gt;Typy zmiennoprzecinkowe posiadają właściwości statyczne &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PositiveInfinity&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NegativeInfinity&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NaN&lt;/strong&gt;. Można porównać wartość z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PositiveInfinity&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NegativeInfinity&lt;/strong&gt; ale nie można porównać z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NaN&lt;/strong&gt;. &lt;br /&gt;Zamiast porównywania można użyć specjalnych metod sprawdzających:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsInfinity&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli wartość jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PositiveInfinity&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NegativeInfinity&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNegativeInfinity&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli wartość jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NegativeInfinity&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsPositiveInfinity&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli wartość jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PositiveInfinity&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNaN&lt;/strong&gt; - zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli wartość jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NaN&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Właściwości wyjątków&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Exception&lt;/strong&gt; jest przodkiem wszystkich klas wyjątków i definiuje kilka właściwości mówiących programowi o tym co się wydarzyło i jaki problem wystąpił, są to właściwości:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Data&lt;/strong&gt; - Kolekcja par klucz/wartość dająca dodatkowe informacje o wyjątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HelpLink&lt;/strong&gt; - Łącze do pliku pomocy powiązanego z wyjątkiem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;HResult&lt;/strong&gt; - Numeryczny kod wyjątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InnerException&lt;/strong&gt; - Wyjątek wewnętrzny posiadający więcej informacji o błędzie który wystąpił.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; - Wiadomość opisująca wyjątek.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Source&lt;/strong&gt; - Nazwa aplikacji lub obiektu zgłaszającego wyjątek.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StackTrace&lt;/strong&gt; - Tekstowa reprezentacja stosu wywołań prowadzącego do wystąpienia wyjątku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TargetSite&lt;/strong&gt; - Informacje o metodzie zgłaszającej wyjątek. &lt;br /&gt;Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; nie zawiera wystarczająco dokładnych informacji aby wyświetlić je użytkownikowi lecz czasem jest wystarczająca dla programisty w czasie usuwania błędów. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; posiada więcej użytecznych dla programisty informacji. Zawiera nazwę klasy wyjątku, właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; oraz stos wywołań. Przykładowo metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OverflowException&lt;/strong&gt; może zwrócić następujący tekst:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;System&lt;span style="box-sizing: border-box; outline: none !important;"&gt;.OverflowException&lt;/span&gt;: Arithmetic operation resulted &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; an &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;overflow&lt;/span&gt;.&lt;br /&gt;    at OrderProcessor&lt;span style="box-sizing: border-box; outline: none !important;"&gt;.OrderForm&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;.CalculateSubtotal&lt;/span&gt;() &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt;&lt;br /&gt;        d:\Support\Apps\OrderProcessor\OrderForm&lt;span style="box-sizing: border-box; outline: none !important;"&gt;.cs&lt;/span&gt;:line &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;166&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wyrzucanie i ponowne wyrzucanie wyjątków&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda może używać bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; do przechwytywania wyjątków. Jeżeli ta metoda posiada interakcję z użytkownikiem to prawdopodobnie wyświetli wiadomość o wystąpieniu błędu. &lt;br /&gt;Jednakże bardzo często metody nie powinny mieć interakcji z użytkownikiem. Zamiast tego powinny wyrzucać wyjątki do ich właścicieli aby powiedzieć wywołującemu kodowi, że wydarzył się błąd. Ten kod może wyświetlić informację użytkownikowi lub może poradzić sobie z problemem, nie przeszkadzając użytkownikowi.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Użycie wyjątków i zwracanie wartości&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda może wykonywać jakąś akcję po czym zwrócić informację do wywołującego ją kodu poprzez wartość zwracaną lub parametr wyjściowy. Wyjątek daje metodzie kolejną możliwość komunikacji z wywołującym ją kodem. Wyjątek mówi programowi, że coś wyjątkowego się wydarzyło i, że metoda mogła nie zakończyć powierzonego jej zadania. &lt;br /&gt;Zdania na temat tego, kiedy metody powinny zwracać wartość za pomocą wartości lub parametru oraz kiedy powinny zwracać informacje za pomocą wyjątków, są podzielone. Większość programistów zgadza się z tym, że informacje o normalnym statusie powinny być zwracane za pomocą wartości a wyjątki powinny być używane dla błędów. &lt;br /&gt;Najlepszą metodą aby zdecydować czy użyć wyjątku jest zadanie pytania czy wywołujący kod może pozwolić na ignorowanie zwracanego przez metodę statusu. Jeżeli metoda zwraca informację za pomocą wartości to wywołujący kod może ją zignorować. Jeżeli metoda zwraca wyjątek to wywołujący kod musi zawierać blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch&lt;/strong&gt; aby obsłużyć jawnie wyjątek. Na przykład, rozważmy następującą metodę, która zwraca silnię liczby:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Calculate&lt;/span&gt; a number's factorial.&lt;br /&gt;private long &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Factorial&lt;/span&gt;(long n)&lt;br /&gt;{&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Make&lt;/span&gt; sure n &amp;gt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (n &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;) &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;    checked&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            long &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (long i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;; i &amp;lt;= n; i++) &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; *= i;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;        catch&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeśli parametr jest mniejszy niż zero lub jeśli obliczenie powoduje przepełnienie liczby całkowitej to metoda zwraca wartość 0. &lt;br /&gt;Istnieją dwa problemy z takim podejściem. Po pierwsze, kod wywołujący może zignorować błąd i traktować wartość 0 jako wartość silni dając nieprawidłowe wyniki. Jeżeli wartość jest używana w złożonych obliczeniach to błąd może wystąpić w trakcie obliczeń co może być trudne do zlokalizowania i naprawienia. Drugim problemem jest to, że kod wywołujący nie może powiedzieć, co poszło nie tak. Można zwracać różne wartości, np 0 dla przepełnienia zakresu liczby całkowitej i -1 dla wartości parametru mniejszego od 0, lecz nawet używając różnych kodów zwracających status nie możemy sprawdzić czy kod nie został zignorowany. Lepszym rozwiązaniem jest wyrzucenie odpowiedniego wyjątku. poniższa wersja metody jest lepszym rozwiązaniem:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Calculate&lt;/span&gt; a number's factorial.&lt;br /&gt;private long &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Factorial&lt;/span&gt;(long n)&lt;br /&gt;{&lt;br /&gt;    // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Make&lt;/span&gt; sure n &amp;gt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;.&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (n &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;) throw new &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ArgumentOutOfRangeException&lt;/span&gt;(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"n"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The number n must be at least 0 to calculate n!"&lt;/span&gt;);&lt;br /&gt;    checked&lt;br /&gt;    {&lt;br /&gt;        long &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (long i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;; i &amp;lt;= n; i++) &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; *= i;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli parametr jest mniejszy niż zero to kod wyrzuci wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArgumentOutOfRangeException&lt;/strong&gt;. Ponieważ obliczenia są zagnieżdżone w bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;checked&lt;/strong&gt; to jeżeli nastąpi przepełnienie zakresu liczby całkowitej to zostanie wyrzucony wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OverflowException.&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Przechwytywanie, wyrzucanie i ponowne wyrzucanie wyjątków&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli metoda wyjaśnia dlaczego wyjątek wystąpił a nie raportuje, że wystąpił lub jeżeli dodaje dodatkowe informacje sprawiając, że wyjątek jest bardziej specyficzny to metoda powinna przechwycić wyjątek i wyrzucić nowy zawierający nowe informacje. &lt;br /&gt;Jeżeli wyrzucamy wyjątek w ten sposób to dobrą praktyką jest zawarcie oryginalnego wyjątku we właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InnerException&lt;/strong&gt; wyrzucanego wyjątku. &lt;br /&gt;Jeżeli metoda dodaje nowe informacje do wyjątku to zwykle nie powinna go przechwytywać lecz pozwolić na przejście wyżej w drzewie wywołań. Czasami chcemy jednak przechwycić taki wyjątek w celu wykonania pewnej “prywatnej” akcji jak np logowanie. W takim przypadku można wykonać prywatny kod obsługujący wyjątek i ponownie go wyrzucić tak aby mógł zostać przechwycony wyżej w drzewie wywołań. &lt;br /&gt;Ponowne wyrzucenie aktualnego wyjątku polega na użyciu deklaracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;throw&lt;/strong&gt; bez podania wyjątku. Poniższy kod demonstruje tą technikę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    // Do something dangerous.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;catch (Exception)&lt;br /&gt;{&lt;br /&gt;    // Log the error.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;    // Re-throw the exception.&lt;br /&gt;    throw;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można też wyrzucić ponownie wyjątek z jawą jego deklaracją lecz powoduje to zresetowanie drzewa wywołań do aktualnej lokalizacji co może zmylić programistę który próbuje naprawić błąd. Poniższy kod demonstruje tą technikę:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    // Do something dangerous.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;    // Log the error.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;    // Re-throw the exception.&lt;br /&gt;    throw ex;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieją jednak powody dla których chcemy ponownie wyrzucać wyjątki i resetować drzewo wywołań, np kiedy nie chcemy pokazywać detali zamkniętej biblioteki i jej prywatnych metod. W takim wypadku powinniśmy obsłużyć wyjątek w metodzie publicznej i wtedy wyrzucić go ponownie tak aby drzewo wywołań zaczynało się w tej metodzie publicznej.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Tworzenie niestandardowych wyjątków&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Czasami nie możemy znaleźć w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; odpowiedniej klasy wyjątku która odpowiada naszym potrzebom. W takim wypadku możemy utworzyć własną klasę wyjątku. &lt;br /&gt;Klasa wyjątku powinna dziedziczyć z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; i jej nazwa powinna być zakończona słowem &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Exception&lt;/em&gt;. &lt;br /&gt;Aby klasa była jak najbardziej użyteczna powinniśmy nadać jej konstruktor pasujący do zdefiniowanego w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt;. Poniższy kod prezentuje klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidException&lt;/strong&gt; napisaną wg powyższych zaleceń:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Serializable&lt;/span&gt;]&lt;br /&gt;class InvalidProjectionException : Exception&lt;br /&gt;{&lt;br /&gt;    public InvalidProjectionException&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;&lt;br /&gt;        : base&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt; { }&lt;br /&gt;    public InvalidProjectionException&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;/span&gt; message)&lt;/span&gt;&lt;br /&gt;        : base&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;)&lt;/span&gt; { }&lt;br /&gt;    public InvalidProjectionException&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;/span&gt; message,&lt;br /&gt;    Exception innerException)&lt;/span&gt;&lt;br /&gt;        : base&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;message&lt;/span&gt;, innerException)&lt;/span&gt; { }&lt;br /&gt;    protected InvalidProjectionException&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;SerializationInfo&lt;/span&gt; info, &lt;br /&gt;        StreamingContext context)&lt;/span&gt;&lt;br /&gt;        : base&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;info&lt;/span&gt;, context)&lt;/span&gt; { }&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Każdy z konstruktorów przekazuje parametry do konstruktora klasy bazowej. Typy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SerializationInfo&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StreamingContext&lt;/strong&gt; są zdefiniowane w przestrzeni nazw &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Runtime.Serialization&lt;/strong&gt;. &lt;br /&gt;Aby wyjątki mogły być przekazywane poza granice domeny aplikacji należy umożliwić im serializację poprzez dodanie atrybutu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serialize&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Użycie Debug.Assert&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Diagnostics.Debug&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; która jest często używana do sprawdzania poprawności danych wstawianych do metody. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; pobiera wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;bool&lt;/em&gt; jako pierwszy parametr i wyrzuca wyjątek jeżeli ta wartość to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;false&lt;/em&gt;. Inne parametry pozwalaja na określenie i wyświetlenie informacji gdzie metoda zawiodła. &lt;br /&gt;W kompilacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;debug&lt;/em&gt; metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; zatrzymuje wykonywanie i wyświetla drzewo wywołań. W kompilacji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;release&lt;/em&gt; program pomija wywołanie tej metody. &lt;br /&gt;Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt; można użyć do zweryfikowania czy wprowadzone dane mają sens. Przykładowo metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;PrintInvoice&lt;/em&gt; pobiera na wejściu tablicę obiektów klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;OrderItem&lt;/em&gt; nazwaną &lt;em style="box-sizing: border-box; outline: none !important;"&gt;items&lt;/em&gt; i wyświetla faktury dla tych obiektów. Metoda ta może zaczynać się od użycia metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Assert&lt;/strong&gt;sprawdzającej czy tablica wejściowa jest mniejsza niż 100:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Debug&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Assert&lt;/span&gt;(items.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Length&lt;/span&gt; &amp;lt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;100&lt;/span&gt;)&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Delegaty&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Delegata&lt;/strong&gt; jest tpem reprezentującym rodzaj metody. Definiuje parametry metody i typ zwracany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zazwyczaj nazwa delegaty nazywana jest z końcówką &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Delegate&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Callback&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można użyć operatorów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;+&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;-&lt;/strong&gt; do kombinowania zmiennych delegat np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;del3 = del1 + del2&lt;/em&gt; to delegata &lt;em style="box-sizing: border-box; outline: none !important;"&gt;del3&lt;/em&gt; wykona metody z obu delegat.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli zmienna delegaty odwołuje się do metody instancji obiektu to wykonuje się na obiekcie do którego została przypisana.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kowariancja pozwala metodzie zwrócić wartość z podklasy typu który został zadeklarowany jako zwracany przez delegatę.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kontrawariancja pozwala metodzie przyjąć parametr z klasy bazowej typu który był oczekiwany przez delegatę.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; definiuje dwa wbudowane typy delegat &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Func&lt;/strong&gt; np:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; Action&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T1, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T2&amp;gt;(T1 arg1, T2 arg2)&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;delegate&lt;/span&gt; TResult Func&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T1, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; T2, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;out&lt;/span&gt; TResult&amp;gt;&lt;br /&gt;(T1 arg1, T2 arg2)&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda anonimowa to metoda bez nazwy np:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Func&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt;&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;function&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;delegate&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt; x) { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x * x; };&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyrażenia lambda pozwalają na tworzenie metod anonimowych w zwięzły sposób np:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Action&lt;/span&gt; note1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt; =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MessageBox&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Show&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Hi"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&amp;gt; note2 = message =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MessageBox&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Show&lt;/span&gt;(message);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&amp;gt; note3 = (message) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MessageBox&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Show&lt;/span&gt;(message);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&amp;gt; note4 = (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; message) =&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MessageBox&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Show&lt;/span&gt;(message);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Func&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt;&amp;gt; square = (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;float&lt;/span&gt; x) =&amp;gt; x * x;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Zdarzenia&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zdarzenia posiadają wydawców i subskrybentów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Do definicji zdarzeń używamy delegat w następujący sposób:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;delegate&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;OverdrawnEventHandler&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; OverdrawnEventHandler Overdrawn;&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można użyć zdefiniowanej delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Action&lt;/strong&gt; do utworzenia zdarzenia np:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; Action Overdrawn;&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zaleca się aby pierwszym parametrem zdarzenia był obiekt nadawcy a następne parametry dające więcej informacji o zdarzeniu. Obiekt nadawcy powinien dziedziczyć z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventArgs&lt;/strong&gt; i mieć nazwę zakończona &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Args&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Można użyć zdefiniowanej delegaty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EventHandler&lt;/strong&gt; aby zdefiniować zdarzenie pobierające obiekt nazwany &lt;em style="box-sizing: border-box; outline: none !important;"&gt;sender&lt;/em&gt; jako pierwszy argument i obiekt danych zdarzenia jako drugi np:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;event&lt;/span&gt; EventHandler&amp;lt;OverdrawnEventArgs&amp;gt; Overdrawn;&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zgłaszaj zdarzenia jak w poniższym kodzie:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (EventName != &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;null&lt;/span&gt;) EventName(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;arguments&lt;/span&gt;...);&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasy nie mogą dziedziczyć zdarzen. Aby klasy mogły zgłaszać zdarzenia klas bazowych używa się metod nazywanych w stylu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OnEventName&lt;/strong&gt; zgłaszających zdarzenie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Program używa operatorów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;+=&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;-=&lt;/strong&gt; do zapisywania się i wypisywania z subskrypcji zdarzeń.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli program zapiszę się na subskrypcję zdarzenia więcej niż raz to obsługa zdarzenia zostanie wykonana wiele razy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli program wypisze się z subskrypcji zdarzenia nawet jeżeli nie był na nią wcześniej zapisany to nic się nie wydarzy.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wyjątki&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Obsługa wyjątków jest procesem ochrony programu od nieoczekiwanych błędów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; musi mieć co najmniej jedną sekcję &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt; jest zawsze wykonywana.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Najbardziej specyficzna sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; powinna pojawić się jako pierwsza w bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli nie chcemy robić nic ze zgłoszonym wyjątkiem to możemy ominąć zmienną wyjątku pozostawiając tylko jego typ w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Exception&lt;/strong&gt; jest klasą bazową wszystkich wyjątków i przechwytuje wszystkie rodzaje wyjątków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Sekcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; bez zdefiniowanego typu wyjątku przechwytuje wszystkie wyjątki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyrażenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; jest równoważne z blokiem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;try-catch-finally&lt;/strong&gt; w którym w sekcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;finally&lt;/strong&gt; obiekt jest zbyty.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyjątek przechodzi w górę drzewa wywołan aż napotka blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;catch&lt;/strong&gt; który go obsłuży.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; wyjątku posiada informacje o wyjatku. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; zawiera właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Message&lt;/strong&gt; oraz dodatkowe opcję wraz z drzewem wywołań.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SqlException&lt;/strong&gt; reprezentuje wyjątki serwera &lt;em style="box-sizing: border-box; outline: none !important;"&gt;SQL Server&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Ponowne wyrzucenie wyjątku polega na użyciu instrukcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;throw&lt;/strong&gt; bez podania obiektu wyjątku. Można również wyrzucić ponownie wyjątek z obiektem lecz powoduje to zresetowania drzewa wywołań.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 26 Nov 2015 20:09:33 Z</pubDate>
      <a10:updated>2015-11-26T20:09:33Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1122</guid>
      <link>http://smsoft.pl/blog/iv-tworzenie-i-implementacja-hierarchii-klas/</link>
      <title>IV. Tworzenie i implementacja hierarchii klas</title>
      <description>&lt;p&gt; &lt;/p&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2&gt;&lt;span style="font-size: 32px;"&gt;&lt;span style="color: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dziedziczenie z klasy bazowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wywoływanie konstruktorów klasy potomnej lub tej samej klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Tworzenie i implementacja interfejsów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie standardowych interfejsów jak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; i destruktor.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Dziedziczenie z klasy bazowej&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Poniższy kod definiuje klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; firstName, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; lastName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Validate the first and last names.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; ((firstName == &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;) || (firstName.Length &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;))&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArgumentOutOfRangeException(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"firstName"&lt;/span&gt;, firstName,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"FirstName must not be null or blank."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; ((lastName == &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;) || (lastName.Length &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;))&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArgumentOutOfRangeException(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"lastName"&lt;/span&gt;, lastName,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"LastName must not be null or blank."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Save the first and last names.&lt;/span&gt;&lt;br /&gt;        FirstName = firstName;&lt;br /&gt;        LastName = lastName;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; posiada dwie właściwości typu tekstowego: &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt;. jej konstruktor pobiera imię i nazwisko jako parametry, wykonuje ich walidację i zapisuje jako właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt;. &lt;br /&gt;Załóżmy, że chcemy utworzyć klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; posiadającą właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DepartmentName&lt;/em&gt;. Możemy zbudować tą klasę w całości lecz potrzebuje ona tych samych właściwości co klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; i może potrzebować również takiej samej walidacji więc budowanie jej w całości byłoby powtórzeniem pracy. Lepszym rozwiązaniem jest dziedziczenie klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; w taki sposób aby odziedziczyła pola, właściwości, metody i zdarzenia. Logicznie pracownik jest pewnym rodzajem osoby więc sensowne jest stwierdzenie, że klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; jest rodzajem klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;. &lt;br /&gt;Dziedziczenie klasy z innej jest zapisywane w postaci nazwy klasy, dwukropka i nazwy klasy z której dziedziczy. Poniższy kod przedstawia dziedziczenie klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Employee&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; DepartmentName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; dziedziczy z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; wszystkie pola,właściwości, metody i zdarzenia. W ciele klasy dodana jest nowa właściwość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DepartmentName&lt;/em&gt;. &lt;br /&gt;Pomimo dziedziczenia większości kodu ciała klasy rodzica, potomek nie dziedziczy konstruktorów. &lt;br /&gt;W tym momencie utworzenie obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; bez inicjalizacji właściwości wygląda tak:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/span&gt; employee = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ kod nie inicjuje właściwości to właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt; mają wartość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt; co jest sprzeczne z walidacją w konstruktorze klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;. Rozwiązaniem tego problemu jest wywołanie konstruktora rodzica przez konstruktor klasy potomka.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wywołanie konstruktora klasy rodzica&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby być pewnym, że konstruktor klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; jest wywoływany i sprawdza poprawność imienia i nazwiska, należy nadać klasie potomnej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; konstruktor zawierający parametry klasy rodzica oraz dodać po dwukropku słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;base&lt;/strong&gt; które sprawi, że zostanie wywołany odpowiedni konstruktor klasy rodzica. Przykład klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; wywołującej konstruktor klasy bazowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Employee&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; DepartmentName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Employee&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; firstName, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; lastName,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; departmentName)&lt;/span&gt;&lt;br /&gt;            : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;base&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(firstName, lastName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Validate the department name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; ((departmentName == &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;null&lt;/span&gt;) || (departmentName.Length &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;))&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArgumentOutOfRangeException(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"departmentName"&lt;/span&gt;, departmentName,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"DepartmentName must not be null or blank."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Save the department name.&lt;/span&gt;&lt;br /&gt;        DepartmentName = departmentName;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konstruktor klasy bazowej jest wywoływany przed ciałem konstruktora klasy potomka. Jeżeli kasa bazowa ma wiele konstruktorów to można użyć każdego z nich. program decyduje którego konstruktora użyć na podstawie parametrów w nawiasie po słowie kluczowym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;base&lt;/strong&gt;. &lt;br /&gt;Jeżeli obie klasy bazowa i potomka posiadają konstruktory to konstruktor potomka musi wywoływać jeden z konstruktorów klasy rodzica co oznacza, że użycie klauzuli ze słowem kluczowym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;base&lt;/strong&gt; jest wtedy wymagane. W przeciwnym wypadku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VisualStudio&lt;/em&gt; wygeneruje błąd: &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“PersonHierarchy.Person Does Not Contain a Constructor That Takes 0 Arguments”&lt;/em&gt;. &lt;br /&gt;Jeżeli klasa potomka nie posiada konstruktora to nie musi wywoływać konstruktora klasy bazowej tzn, że taka deklaracja jest poprawna:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Employee&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; DepartmentName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wywołanie konstruktora tej samej klasy&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;bardzo często klasy posiadają wiele konstruktorów wykonujących różne rodzaje inicjalizacji w zależności od wprowadzonych parametrów wejściowych. Czasem wiele konstruktorów musi wykonywać te same zadania. &lt;br /&gt;Przykładowo klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; posiadająca właściwości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;LastName&lt;/em&gt; może być inicjowana poprzez podanie imienia lub imienia i nazwiska:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Constructor with first name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; firstName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        FirstName = firstName;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Constructor with first and last name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; firstName, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; lastName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        FirstName = firstName;&lt;br /&gt;        LastName = lastName;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Drugi konstruktor klasy wykonuje tę samą czynność co pierwszy konstruktor czyli inicjuje właściwość &lt;em style="box-sizing: border-box; outline: none !important;"&gt;FirstName&lt;/em&gt;. W tym przykładzie to nie jest duży problem ale w bardziej skomplikowanym przykładzie mogłoby być to wiele powtarzającego się kodu. &lt;br /&gt;Aby temu zapobiec można pozwolić konstruktorowi wywoływać inny konstruktor. Wykonuje się to tak samo jak wywoływanie konstruktora bazowego tylko, że przy użyciu słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;this&lt;/strong&gt;. Przykład konstruktora wywołującego inny konstruktor:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Constructor with first and last name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; firstName, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; lastName)&lt;/span&gt;&lt;br /&gt;: &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;this&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(firstName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    LastName = lastName;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konstruktor wskazany słowem kluczowym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;this&lt;/strong&gt; jest wykonywany przed ciałem konstruktora który go wywołuje.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Interfejsy&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy wiemy już jak dziedziczyć pomiędzy klasami to możemy budować diagramy używające strzałek pokazujących relacje pomiędzy klasami. Język &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C#&lt;/strong&gt; pozwala na posiadanie jednej klasy rodzica więc rezultatem takiego diagramu jest drzewiasta hierarchia. &lt;br /&gt;Hierarchie klasowe są wystarczające dla wielu różnych problemów modelowania, ale od czasu do czasu byłoby wygodne, aby umożliwić klasom dziedziczenie z wielu klas bazowych. Przykładowo pisząc program zarzadzający studentami i pracownikami uniwersytetu. Dwie ważne klasy to klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; reprezentująca osobę studiującą i klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Faculty&lt;/strong&gt;reprezentująca osobę nauczającą. Problem pojawia się kiedy chcemy dodać klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt; reprezentującą asystenta wykładowcy który jest jednocześnie studentem. Idealnym rozwiązaniem byłoby użycie wielokrotnego dziedziczenia tak aby klasa mogła dziedziczyc jednocześnie z klas &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Faculty&lt;/strong&gt;. Niestety w języku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C#&lt;/strong&gt; jest to niemożliwe. &lt;br /&gt;Zamiast użycia wielokrotnego dziedziczenia w języku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C#&lt;/strong&gt; można użyć interfejsów aby zasymulować takie dziedziczenie. &lt;br /&gt;Interfejs wymaga klasy aby zapewnić pewne funkcje tak samo jak klasa bazowa lecz w przeciwieństwie do klasy bazowej interfejs nie posiada implementacji. Ponieważ używanie interfejsu jest podobne do dziedziczenia bez implementacji to nazywane jest dziedziczeniem interfejsu. Każda klasa może dziedziczyć tylko z jednej klasy bazowej ale może implementować dowolną liczbę interfejsów.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Definiowanie interfejsów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Interfejs tak samo jak klasa posiada właściwości, metody i zdarzenia ale nie posiada kodu który je implementuje. Jest formą kontraktu określającego cechy jakie inna klasa powinna implementować. &lt;br /&gt;Jeżeli klasa implementuje interfejs to musi implementować cechy zdefiniowane w interfejsie. Mówi to programowi, że ta klasa ma te cechy więc kod może je wywoływać. &lt;br /&gt;Wprowadza to rodzaj polimorfizmu podobny do tego w jaki klasy mogą być traktowane przez program jako obiekty innych klas kompatybilnych. Przykładowo klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; dziedziczy z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; i implementuje interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ICloneable&lt;/strong&gt;. Program może traktować obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt; jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Employee&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ICloneable&lt;/strong&gt;. &lt;br /&gt;Przykład interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;interface&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IStudent&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The student's list of current courses.&lt;/span&gt;&lt;br /&gt;    List&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; Courses { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Print the student's current grades.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;PrintGrades&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Wg konwencji nazwy interfejsów rozpoczynamy od dużej litery I np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IStudent&lt;/em&gt;.&lt;/strong&gt;&lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; implementująca interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent&lt;/strong&gt; i dziedzicząca z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Student&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Person&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;IStudent&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Implement IStudent.Courses.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The student's list of current courses.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; List&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; Courses { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Implement IStudent.PrintGrades.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Print the student's current grades.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; PrintGrades()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do whatever is necessary...&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt; dziedzicząca z klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Faculty&lt;/strong&gt; i implementująca interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;TeachingAssistant&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Faculty&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;IStudent&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Implement IStudent.Courses.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The student's list of current courses.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; List&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; Courses { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Implement IStudent.PrintGrades.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Print the student's current grades.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; PrintGrades()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do whatever is necessary...&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Implementacja interfejsów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Czasami implementacja wszystkich metod zdefiniowanych przez interfejs może być dużą ilością pracy. Na szczęście &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VisualStudio&lt;/em&gt; posiada narzędzia ułatwiające implementację interfejsów. Deklarując interfejs do implementacji w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VisualStudio&lt;/em&gt; klikamy prawym przyciskiem myszy na nazwie interfejsu i z menu kontekstowego wybieramy opcję &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Implement Interface&lt;/em&gt;lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Implement Interface Explicitly&lt;/em&gt;. Przykład kodu wygenerowanego przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;VisualStudio&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Explicit implementation.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;TeachingAssistant&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Faculty&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;IStudent&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    List&amp;lt;string&amp;gt; IStudent.Courses&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NotImplementedException();&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NotImplementedException();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; IStudent.PrintGrades()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; NotImplementedException();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Opcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Explicitly&lt;/strong&gt; powoduje, że przed każdą metodą i właściwością dodane jest cześć z której jest implementowana czyli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent.&lt;/strong&gt;. Wygenerowane części kodu wyrzucają wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NotImplementedException&lt;/strong&gt; kiedy zostaną wywołane. Tę część kodu należy zamienić na odpowiedni kod logiki aplikacji. &lt;br /&gt;Oprócz różnic w składni istnieje funkcjonalna różnica pomiędzy niejawną i jawną implementacją interfejsu. Jeśli klasa implementuje interfejs jawnie to program nie może odnieść się do członków interfejsu za pośrednictwem instancji klasy. Zamiast tego musi użyć instancji interfejsu. &lt;br /&gt;Przykładowo klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt; implementuje jawnie interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;TeachingAssistant &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ta&lt;/span&gt; = new TeachingAssistant();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The following causes a design time error.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ta&lt;/span&gt;.PrintGrades();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The following code works.&lt;/span&gt;&lt;br /&gt;IStudent student = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ta&lt;/span&gt;;&lt;br /&gt;student.PrintGrades();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli klasa implementuje interfejs niejawnie to program ma dostęp do członków interfejsu z instancji klasy i z instancji interfejsu.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Delegowanie interfejsów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Obie klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt; implementuja interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent&lt;/strong&gt;, więc obie zawierają kod zapewniający cechy interfejsu. Kod ten jest zduplikowany. &lt;br /&gt;Aby uniknąć duplikowania kodu w klasie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt; można użyć delegacji do klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; w której ten kod jest już zaimplementowany. Delegowanie odbywa się poprzez umieszczenie obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; w ciele klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt;. &lt;br /&gt;Ilekroć klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TeachingAssistant&lt;/strong&gt; będzie musiała wykonać pewną czynność wyspecyfikowaną w interfejsie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IStudent&lt;/strong&gt; użyje obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Student&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Delegate IStudent to a Student object.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;TeachingAssistant&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Faculty&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;IStudent&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// A Student object to handle IStudent.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; Student MyStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; List&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;&amp;gt; Courses&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; MyStudent.Courses;&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            MyStudent.Courses = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; PrintGrades()&lt;br /&gt;    {&lt;br /&gt;        MyStudent.PrintGrades();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Implementacja popularnych interfejsów&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; zawiera wiele interfejsów które wspomagają pracę klas. Poniżej opisane zostaną najważniejsze z nich.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;IComparable&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CompareTo&lt;/strong&gt; która umożliwia programowi porównanie dwóch instancji klas i zdecydowanie który z obiektów jest pierwszy w kolejności sortowania. Przykładowo klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Car&lt;/strong&gt; służy do przechowywania modeli samochodów i chcemy aby obiekty tej klasy były sortowane wg nazwy. Możemy stworzyć klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Car&lt;/strong&gt; tak aby implementowała interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; i użyć metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Array.Sort&lt;/strong&gt; do sortowania tablicy z obiektami klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Car&lt;/strong&gt;. &lt;br /&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; posiada dwie wersje: zwykłą i generyczną. Wersja zwykła interfejsu istnieje dla zgodności z poprzednimi wersjami &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET rameworka&lt;/strong&gt;. Zaleca się używanie wersji generycznej. &lt;br /&gt;Jeżeli użyjemy zwykłej wersji to metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CompareTo&lt;/strong&gt; pobierze dwa niespecyfikowane obiekty jako parametry po czym w kodzie trzeba je skonwertować na obiekty klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Car&lt;/strong&gt; przed porównaniem ich nazw np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Car&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IComparable&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Name { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; MaxMph { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Horsepower { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt; Price { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Compare Cars alphabetically by Name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;CompareTo&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; obj)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!(obj &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;is&lt;/span&gt; Car))&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; ArgumentException(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Object is not a Car"&lt;/span&gt;);&lt;br /&gt;        Car other = obj &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;as&lt;/span&gt; Car;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; Name.CompareTo(other.Name);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wersja generyczna implementacji interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; dla klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Car&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;class Car : IComparable&amp;lt;Car&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; string Name { &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; MaxMph { &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; Horsepower { &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; decimal Price { &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Compare Cars alphabetically by Name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; CompareTo(Car other)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.Name.CompareTo(other.Name);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;IComparer&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt; pozwala na porównywanie obiektów po wielu różnych właściwościach. Klasa implementująca ten interfejs musi posiadać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Compare&lt;/strong&gt; która porównuje obiekty. Przykładowo można utworzyć klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CarPriceComparer&lt;/strong&gt; która implementuje interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt; i posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Compare&lt;/strong&gt; która porównuje obiekty klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Car&lt;/strong&gt; po właściwości&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Price&lt;/strong&gt;. Można użyć obiektu klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CarPriceComparer&lt;/strong&gt; jako parametru metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Array.Sort&lt;/strong&gt; aby posortować samochody w tablicy wg ceny. &lt;br /&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt; posiada dwie wersje: zwykłą i generyczną. Wersja zwykła interfejsu istnieje dla zgodności z poprzednimi wersjami &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET rameworka&lt;/strong&gt;. Zaleca się używanie wersji generycznej. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CarPriceComparer&lt;/strong&gt; pozwala na sortowanie wg ceny ale ciągle nie pozwala na sortowanie wg maksymalnej prędkości czy też innych właściwości samochodu. Można utworzyć kilka różnych klas implementujących interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt;, ale istnieje prostsze rozwiązanie. jest nim utworzenie jednej klasy implementującej interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt; z polem które mówi po jakim polu ma odbywać się porównywanie. Poniższy kod przedstawia klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CarComparer&lt;/strong&gt; demosntrującą to rozwiązanie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; CarComparer : IComparer&amp;lt;Car&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The field to compare.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; enum CompareField&lt;br /&gt;    {&lt;br /&gt;        Name,&lt;br /&gt;        MaxMph,&lt;br /&gt;        Horsepower,&lt;br /&gt;        Price,&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; CompareField SortBy = CompareField.Name;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Compare(Car x, Car y)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;switch&lt;/span&gt; (SortBy)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; CompareField.Name:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x.Name.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CompareTo&lt;/span&gt;(y.Name);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; CompareField.MaxMph:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x.MaxMph.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CompareTo&lt;/span&gt;(y.MaxMph);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; CompareField.Horsepower:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x.Horsepower.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CompareTo&lt;/span&gt;(y.Horsepower);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; CompareField.Price:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x.Price.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CompareTo&lt;/span&gt;(y.Price);&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; x.Name.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;CompareTo&lt;/span&gt;(y.Name);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;IEquatable&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Equals&lt;/strong&gt; która pozwala na sprawdzenie czy obiekty są sobie równe. &lt;br /&gt;Przykład programu wykorzystującego interfejs:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; Person : IEquatable&amp;lt;Person&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; FirstName { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; LastName { get; &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Equals&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(Person other)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; ((FirstName == other.FirstName) &amp;amp;&amp;amp;&lt;br /&gt;            (LastName == other.LastName));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Program dodający obiekt klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; do listy unikalnych osób:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The List of Persons.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; List&amp;lt;Person&amp;gt; People = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;Person&amp;gt;();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Add a Person to the List.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;btnAdd_Click&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Make the new Person.&lt;/span&gt;&lt;br /&gt;    Person person = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person()&lt;br /&gt;    {&lt;br /&gt;        FirstName = firstNameTextBox.Text,&lt;br /&gt;        LastName = lastNameTextBox.Text&lt;br /&gt;    };&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (People.Contains(person))&lt;br /&gt;    {&lt;br /&gt;        MessageBox.Show(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The list already contains this person."&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        People.Add(person);&lt;br /&gt;        firstNameTextBox.Clear();&lt;br /&gt;        lastNameTextBox.Clear();&lt;br /&gt;        firstNameTextBox.Focus();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Contains&lt;/strong&gt; listy używa faktu, że klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; implementuje interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; do zdecydowania czy obiekt istnieje już w liście. &lt;br /&gt;Jeżeli klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt; nie implementowałaby interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; to metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Contains&lt;/strong&gt; traktowałaby każdy inny obiekt jako nowy bez względu na to czy miały by takie same wartości pól. &lt;br /&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Zaleca się aby każda klasa której obiekty mogą być gromadzone w kolekcjach implementowała interfejs IEquatable.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;ICloneable&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa implementująca interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ICloneable&lt;/strong&gt; musi posiadać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clone&lt;/strong&gt; która zwraca kopię obiektu dla którego jest wywoływana np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ICloneable&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; Person Manager { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Return a clone of this person.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Clone&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Person person = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person();&lt;br /&gt;        person.FirstName = FirstName;&lt;br /&gt;        person.LastName = LastName;&lt;br /&gt;        person.Manager = Manager;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; person;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clone&lt;/strong&gt; zwraca niespecyfikowany obiekt więc kod wywołujący musi rzutować wynik na klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Person&lt;/strong&gt;. Przykład użycia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Person &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;ann =&lt;/span&gt; new Person()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;FirstName =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Ann"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;LastName =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Archer"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Manager =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;null&lt;/span&gt;&lt;br /&gt;};&lt;br /&gt;Person &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;bob =&lt;/span&gt; new Person()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;FirstName =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bob"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;LastName =&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Baker"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;Manager =&lt;/span&gt; ann&lt;br /&gt;};&lt;br /&gt;Person &lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;bob2 =&lt;/span&gt; (Person)bob.Clone();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;IEnumerable&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; wprowadza metody pozwalające na wyliczenia elementów które klasa posiada. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumerator&lt;/strong&gt; zwraca obiekt implementujący interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerator&lt;/strong&gt;. &lt;br /&gt;Obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerator&lt;/strong&gt; wprowadza właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Current&lt;/strong&gt; która zwraca aktualny obiekt w wyliczaniu. Wprowadza także metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MoveNext&lt;/strong&gt; która przesuwa wyliczenie do następnego elementu i metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reset&lt;/strong&gt; która resetuje enumerator do stanu sprzed wyliczania. Wprowadza także metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; która czyści wszystkie użyte zasoby kiedy nie są już potrzebne. &lt;br /&gt;Program poniżej przechowuje informacje o węźle w drzewie:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; TreeNode : IEnumerable&amp;lt;TreeNode&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Depth = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; Text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; List&amp;lt;TreeNode&amp;gt; Children = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;TreeNode&amp;gt;();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;TreeNode&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; text)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Text = text;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Add and create children.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt; TreeNode &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;AddChild&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; text)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        TreeNode child = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; TreeNode(text);&lt;br /&gt;        child.Depth = Depth + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;        Children.Add(child);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; child;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Return the tree's nodes in an preorder traversal.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; List&amp;lt;TreeNode&amp;gt; Preorder()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Make the result list.&lt;/span&gt;&lt;br /&gt;        List&amp;lt;TreeNode&amp;gt; nodes = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; List&amp;lt;TreeNode&amp;gt;();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Traverse this node's subtree.&lt;/span&gt;&lt;br /&gt;        TraversePreorder(nodes);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Return the result.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; nodes;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;TraversePreorder&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(List&amp;lt;TreeNode&amp;gt; nodes)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Traverse this node.&lt;/span&gt;&lt;br /&gt;        nodes.Add(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Traverse the children.&lt;/span&gt;&lt;br /&gt;        foreach (TreeNode child in Children)&lt;br /&gt;        child.TraversePreorder(nodes);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; IEnumerator&amp;lt;TreeNode&amp;gt; GetEnumerator()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; TreeEnumerator(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;    IEnumerator IEnumerable.GetEnumerator()&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; TreeEnumerator(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TreeEnumerator&lt;/strong&gt; definiująca obiekty które potrafią enumerować drzewo stworzone z obiektów klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TreeNode&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; TreeEnumerator : IEnumerator&amp;lt;TreeNode&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The tree's nodes in their proper order.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; List&amp;lt;TreeNode&amp;gt; Nodes;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// The index of the current node.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; CurrentIndex;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Constructor.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;TreeEnumerator&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(TreeNode root)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Nodes = root.Preorder();&lt;br /&gt;        Reset();&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt; TreeNode Current&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; GetCurrent(); }&lt;br /&gt;    }&lt;br /&gt;    object IEnumerator.Current&lt;br /&gt;    {&lt;br /&gt;        get { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; GetCurrent(); }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt; TreeNode &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetCurrent&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (CurrentIndex &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; InvalidOperationException();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (CurrentIndex &amp;gt;= Nodes.Count)&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; InvalidOperationException();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; Nodes[CurrentIndex];&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MoveNext&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        CurrentIndex++;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; (CurrentIndex &amp;lt; Nodes.Count);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Reset&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        CurrentIndex = -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Dispose&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TreeNode&lt;/strong&gt; implementuje interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; a klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TreeEnumerator&lt;/strong&gt; implementuje interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerator&lt;/strong&gt; to program ich używający może enumerować po drzewie złożonym z obiektów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TreeNode&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Build and display a tree.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; Form1_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Build the tree.&lt;/span&gt;&lt;br /&gt;    TreeNode president = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; TreeNode(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"President"&lt;/span&gt;);&lt;br /&gt;    TreeNode sales = president.AddChild(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"VP Sales"&lt;/span&gt;);&lt;br /&gt;    sales.AddChild(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Domestic Sales"&lt;/span&gt;);&lt;br /&gt;    sales.AddChild(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"International Sales"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Other tree-building code omitted.&lt;/span&gt;&lt;br /&gt;    ...&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display the tree.&lt;/span&gt;&lt;br /&gt;    string &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;text&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;;&lt;br /&gt;    IEnumerator&amp;lt;TreeNode&amp;gt; enumerator = president.GetEnumerator();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (enumerator.MoveNext())&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;text&lt;/span&gt; += &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; string(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;' '&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt; * enumerator.Current.Depth) +&lt;br /&gt;            enumerator.Current.Text +&lt;br /&gt;            Environment.NewLine;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;text&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;text&lt;/span&gt;.Substring(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;text&lt;/span&gt;.Length - Environment.NewLine.Length);&lt;br /&gt;    treeTextBox.Text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;text&lt;/span&gt;;&lt;br /&gt;    treeTextBox.Select(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; wymaga dużo pracy w tym zaimplementowanie kilku metod oraz dodanie klasy pomocniczej implementującej interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerator&lt;/strong&gt;. Jeżeli program wymaga tylko wykonywania pętli na zbiorze obiektów to istnieje łatwiejsza metoda. &lt;br /&gt;Należy dodać do klasy metodę zwracającą obiekt typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt;, gdzie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;class&lt;/em&gt; jest klasą z którą pracujemy. Niech metoda znajdzie wszystkie obiekty które mają być wyliczane i niech wywoła dla każdego z nich &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;yield return&lt;/strong&gt;. Na koniec wyliczania metoda musi wywołać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;yield break&lt;/strong&gt;. &lt;br /&gt;Poniższy kod pokazuje klasę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TreeNode&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Return an enumerator.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt; IEnumerable&amp;lt;TreeNode&amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetTraversal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Get the preorder traversal.&lt;/span&gt;&lt;br /&gt;    List&amp;lt;TreeNode&amp;gt; traversal = Preorder();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Yield the nodes in the traversal.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (TreeNode node &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; traversal) &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;yield&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; node;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;yield&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kod wywołuje metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Preorder&lt;/strong&gt; opisaną wcześniej aby pobrać listę węzłów drzewa. &lt;br /&gt;Przykładowe użycie enumeracji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; text = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (TreeNode node &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; president.GetTraversal())&lt;br /&gt;{&lt;br /&gt;    text += &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;' '&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt; * node.Depth) +&lt;br /&gt;        node.Text +&lt;br /&gt;        Environment.NewLine;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Użycie słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;yield&lt;/strong&gt; jest dużo łatwiejsze niż implementacja interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; a rezultat programu jest taki sam.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Zarządzanie cyklem życia obiektów&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kiedy program w języku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C#&lt;/strong&gt; tworzy instancję klasy to powstaje obiekt. Program używa tego obiektu przez pewien czas, lecz od pewnego momentu obiekt może już nie byc potrzebny. Kiedy program traci ostatnią referencję do obiektu, albo poprzez ustawienie wszystkich referencji na &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt; albo wyszły z zakresu (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;scope&lt;/em&gt;), to obiekt przestaje być dostępny dla programu i staje się kandydatem do usunięcia (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;garbage collection&lt;/em&gt;). &lt;br /&gt;W pewnym momencie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;garbage collector&lt;/strong&gt; (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt;) może zdecydować, że programowi zaczyna brakować pamięci i czas rozpocząć usuwanie śmieci. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; zaznacza całą pamięć, która była używana przez program, jako obecnie nieosiągalną (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;unreachable&lt;/em&gt;). Następnie przechodzi przez wszystkie referencje dostępne dla programu i oznacza je jako osiągalne (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;reachable&lt;/em&gt;). Jeżeli referencja odwołuje się do obiektu to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; podąża za nią dopóki nie odwiedzi wszystkich obiektów do których program może się dostać. &lt;br /&gt;Kiedy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; sprawdzi referencje to bada wszystkie obiekty oznaczone jako nieosiągalne. Jeżeli obiekt posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; ją wywołuje w celu wykonania wymaganych porządków. Po wykonaniu metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; czyści pamięć zajętą przez obiekt w celu późniejszego jej użycia. &lt;br /&gt;Proces wywoływania metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; jest nazywany finalizacją. Ponieważ nie można powiedzieć &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; aby uruchomił finalizację obiektu to proces ten nazywa się finalizacją niedeterministyczną. &lt;br /&gt;Proces ten jest prosty dla prostych obiektów ale może być bardziej skomplikowany dla obiektów która mają dostęp do zasobów które uszą być w jakiś sposób oczyszczone. Przykładowo program tworzy obiekt który blokuje plik do zapisu, przykładowo do rejestrowania zdarzeń. Kiedy obiekt przestaje być w zakresie to staje się kandydatem do czyszczenia dla&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt;, lecz nie można powiedzieć &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; kiedy ma sfinalizować ten obiekt a tymczasem plik pozostaje zablokowany pomimo, że nie jest używany przez program. &lt;br /&gt;Można wykonać dwa kroki aby pomóc obiektowi zwolnić jego zasoby: zaimplementować interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; i użyć destruktorów.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Implementacja interfejsu IDisposable&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa implementująca interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; musi posiadać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; która służy do czyszczenia zasobów używanych przez klasę. Program powinien wywoływać metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; lub używać deklaracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; kiedy obiekt nie jest już potrzebny i można wykonać czyszczenie jego zasobów. &lt;br /&gt;Głównym zadaniem metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; jest czyszczenie zasobów niezarządzanych (nie kontrolowanych przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CLR&lt;/strong&gt; np. pliki), ale może również czyścić zasoby zarządzane. jeżeli obiekt używa referencji do innych obiektów implementujących interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt;, to może wywołać ich metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt;. &lt;br /&gt;Przykładowo obiekt klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Shape&lt;/em&gt; reprezentuje kształt rysunku i posiada właściwości które są referencjami do obiektów klas &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Brush&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Pen&lt;/em&gt;. Klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Brush&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Pen&lt;/em&gt; są klasami zarządzanymi implementującymi interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt;, więc wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Shape&lt;/em&gt; czyści jej zasoby. &lt;br /&gt;Innym przykładem może być klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ImageTransformer&lt;/em&gt; która używa kodu niezarządzanego do manipulacji bitmapami. Używa wywołań API aby otrzymać uchwyt do bitmapy (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;HBITMAP&lt;/em&gt;), innych wywołań API aby otrzymać kontekst urządzenia (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;DC&lt;/em&gt;) i innych do manipulacji bitmapami. Wywołania API są kodem niezarządzanym. Jeżeli obiekt &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ImageTransformer&lt;/em&gt; jest niszczony bez użycia wywołania API do usunięcia jego uchwytów, to zajmowana przez nie pamięć jest stracona. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ImageTransformer&lt;/em&gt; powinna użyć odpowiednich metod API do zwolnienia tych zasobów. &lt;br /&gt;Wg konwencji wywołanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; więcej niż jeden raz powinno być bezpieczne dlatego stosuje się zmienną binarną sprawdzającą czy metoda ta była już wywołana na obiekcie, jeżeli tak to metoda nie powinna robić nic więcej. &lt;br /&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; dla obiektów które mogą być używane wielokrotnie zaleca używanie metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Open&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Close&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Destruktory&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; zwalnia zasoby jeżeli program ją wywoła, ale jeżeli program jej nie wywoła to zasoby nie zostaną zwolnione. Kiedy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; niszczy niepotrzebne obiekty to oczyszcza zasoby zarządzane ale zasoby niezarządzane nie zostają zwolnione. Aby zapobiec takiej sytuacji można dodać klasie konstruktor który zwalnia zasoby kiedy obiekt jest niszczony. &lt;br /&gt;Destruktor jest metodą która nie ma typu zwracanego a nazwa jest taka sama jak nazwa klasy z prefiksem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;~&lt;/strong&gt;. &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; wykonuje konstruktor przed zniszczeniem obiektu. &lt;br /&gt;Destruktory posiadają pewne zasady które nie są stosowane do innych metod:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktory mogą być definiowane tylko w klasach, nie w strukturach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa może posiadać tylko jeden destruktor.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor nie może być odziedziczony lub przeciążony.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor nie może być wywołany bezpośrednio.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor nie może posiadać modyfikatorów ani parametrów. &lt;br /&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; wywołuje finalizację obiektu a nie destruktor. Destruktor jest konwertowany na nadpisaną metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; która wykonuje kod destruktora po czym wywołuje metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; klasy bazowej. &lt;br /&gt;Przykładowo klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; posiada taki destruktor:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;~Person()&lt;br /&gt;{&lt;br /&gt;    // Free unmanaged resources here.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Destruktor jest konwertowany na metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;protected override void Finalize()&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;    // Free unmanaged resources here.&lt;br /&gt;    //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;    finally&lt;br /&gt;    {&lt;br /&gt;        base.Finalize();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Nie można bezpośrednio nadpisać metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; w kodzie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; oraz nie można jej bezpośrednio wywołać. &lt;br /&gt;Kiedy wykonywany jest destruktor to &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; jest prawdopodobnie w czasie usuwania innych obiektów więc kod destruktora nie może zależeć od istnienia innych obiektów. Przykładowo klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; posiada referencję do klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Company&lt;/em&gt;. Destruktor klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; nie może zakładać, że obiekt klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Company&lt;/em&gt; nadal istnieje ponieważ mógł być wcześniej zniszczony przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt;. Oznacza to, że destruktor klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; nie może wywoływać metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Company&lt;/em&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Istnieje jeszcze jeden haczyk w zarządzaniu zasobami. jeżeli obiekt posiada destruktor to musi przejść przez kolejkę finalizacji (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;finalization queue&lt;/em&gt;) zanim zostanie zniszczony a to zajmuje dodatkowy czas. Jeżeli metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; zwolniła zasoby obiektu wcześniej to nie ma potrzeby aby uruchamiać destruktor obiektu. W tym wypadku metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; może wywołać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC.SuppressFinalize&lt;/strong&gt; aby &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; nie wywoływał finalizacji obiektu i przeskoczył kolejkę finalizacji przy niszczeniu obiektu. &lt;br /&gt;Podsumowanie zasad i konceptów zarządzania zasobami:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa nie posiada zasobów zarządzanych i niezarządzanych to nie potrzebuje implementować interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; ani posiadać destruktora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa posiada tylko zasoby zarządzane to powinna implementować &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; ale nie potrzebuje destruktora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa posiada zasoby niezarządzane to powinna implementować &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; oraz destruktor w wypadku gdy metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; nie zostanie wywołana przez program.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; musi być zabezpieczona przed jej wielokrotnym wywołaniem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; powinna zwalniać zasoby zarządzane i niezarządzane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor powinien zwalniać tylko zasoby niezarządzane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Po zwolnieniu zasobów metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; powinna wywoływać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC.SuppressFinalize&lt;/strong&gt; aby przeskoczyć kolejkę finalizacji. &lt;br /&gt;Przykład programu z implementacją &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; i destruktorem:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DisposableClass&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IDisposable&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// A name to keep track of the object.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Free managed and unmanaged resources.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Dispose&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        FreeResources(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Destructor to clean up unmanaged resources&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// but not managed resources.&lt;/span&gt;&lt;br /&gt;    ~DisposableClass()&lt;br /&gt;    {&lt;br /&gt;        FreeResources(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Keep track if whether resources are already freed.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;bool&lt;/span&gt; ResourcesAreFreed = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Free resources.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;FreeResources&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;bool&lt;/span&gt; freeManagedResources)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(Name + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": FreeResources"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!ResourcesAreFreed)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Dispose of managed resources if appropriate.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (freeManagedResources)&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Dispose of managed resources here.&lt;/span&gt;&lt;br /&gt;                Console.WriteLine(Name + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": Dispose of managed resources"&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Dispose of unmanaged resources here.&lt;/span&gt;&lt;br /&gt;            Console.WriteLine(Name + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;": Dispose of unmanaged resources"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Remember that we have disposed of resources.&lt;/span&gt;&lt;br /&gt;            ResourcesAreFreed = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// We don't need the destructor because&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// our resources are already freed.&lt;/span&gt;&lt;br /&gt;            GC.SuppressFinalize(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Collect&lt;/strong&gt; wymuszająca uruchomienie oczyszczania śmieci przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; ale używanie jej jest niezalecane ponieważ zaburza normalny cykl algorytmu oczyszczania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC&lt;/strong&gt; co może mieć wpływ na wydajność programu.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie deklaracji using&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli obiekt posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt;, to program który go uzywa powinien ją wywołać po wykonaniu przcy obiektu aby zwolnić jego zasoby. Jest to bardzo ważne ale bardzo łatwe do zapomnienia. Aby można było łatwiej to wywoływać w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; wprowadzono deklarację &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;. &lt;br /&gt;Deklaracja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; rozpoczyna blok kodu który jest związany z obiektem implementującym interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt;. Kiedy blok jest zakończony to program automatycznie wywołuje metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt;. &lt;br /&gt;Przykład użycia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;using (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;DisposableClass&lt;/span&gt; obj = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;DisposableClass&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    obj.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Name&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CreateAndDispose "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important;"&gt;ObjectNumber&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ToString&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ObjectNumber&lt;/span&gt;++;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; wywołuje metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; kiedy jest zakończony, nawet jeżeli kod w środku wyrzuci wyjątek. Poprzedni kod jest ekwiwalentem to poniższego kodu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;{&lt;br /&gt;    DisposableClass obj = new DisposableClass&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    try&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;{&lt;br /&gt;        obj.Name = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"CreateAndDispose "&lt;/span&gt; + ObjectNumber.ToString&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;        ObjectNumber++;&lt;br /&gt;    }&lt;/span&gt;&lt;br /&gt;    finally&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;{&lt;br /&gt;        if &lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;obj&lt;/span&gt; != null)&lt;/span&gt; obj.Dispose&lt;span style="box-sizing: border-box; outline: none !important;"&gt;()&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;br /&gt;    }&lt;/span&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Deklaracja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; posiada trzy formy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Version 1.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (DisposableClass obj1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; DisposableClass())&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Version 2.&lt;/span&gt;&lt;br /&gt;DisposableClass obj2 = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; DisposableClass();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (obj2)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Version 3.&lt;/span&gt;&lt;br /&gt;DisposableClass obj3;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; (obj3 = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; DisposableClass())&lt;br /&gt;{&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pierwsza z metod jest zalecana ponieważ obiekt jest inicjowany w nawiasie i jego zasięg ogranicza się do bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;. &lt;br /&gt;W pozostałych metodach pomimo, że obiekt uruchomił już metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; to jest nadal dostępny w zakresie poza blokiem &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Dziedziczenie&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Język &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; nie zezwala na wielokotne dziedziczenie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;base&lt;/strong&gt; pozwala wywołać konstruktor klasy rodzica w następujący sposób:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public class Employee : Person&lt;br /&gt;    {&lt;br /&gt;        public Employee(string firstName, string lastName)&lt;br /&gt;            : base(firstName, lastName)&lt;br /&gt;        {&lt;br /&gt;            //&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;...&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;this&lt;/strong&gt; pozwala wywołać inny konstruktor tej samej klasy w następujący sposób:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; firstName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        FirstName = firstName;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Person&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; firstName, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; lastName)&lt;/span&gt;&lt;br /&gt;        : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;this&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(firstName)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        LastName = lastName;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konstruktor może wywołać tylko jeden konstruktor klasy bazowej lub jeden konstruktor tej samej klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa bazowa ma konstruktory to konstruktory klasy potomka muszą wywoływać jeden z nich pośrednio lub bezpośrednio.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Interfejsy&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zgodnie z konwencją nazwy interfejsów rozpoczyna się od dużej litery &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;I&lt;/strong&gt; np: &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IComparable&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa może implementować wiele interfejsów jednocześnie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa implementuje interfejs jawnie to kod nie może dostać się do członków interfejsu poprzez instancję obiektu. Zamiast tego musi użyć instancji interfejsu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;jeżeli klasa implementuje interfejs niejawnie to kod może dostać się do członków interfejsu poprzez instancję obiektu jak i interfejsu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparable&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CompareTo&lt;/strong&gt; która określa kolejność obiektów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IComparer&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Compare&lt;/strong&gt; która porównuje dwa obiekty i określa ich kolejność.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEquatable&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Equals&lt;/strong&gt; która sprawdza czy obiekty są sobie równe.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ICloneable&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clone&lt;/strong&gt; która tworzy kopię obiektu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GetEnumerator&lt;/strong&gt; która zwraca obiekt interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerator&lt;/strong&gt; który pozwala na użycie metod &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MoveNext&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Reset&lt;/strong&gt; które umożliwiają przechodzenie przez listę obiektów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda może użyć deklaracji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;yield return&lt;/strong&gt; aby dodac obiekt do wyniku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerator&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Destruktory&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktory mogą być definiowane jedynie w klasach.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa może posiadać tylko jeden destruktor.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor nie może być dziedziczony ani przeciążony.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor nie może być bezpośrednio wywołany.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor nie może posiadać modyfikatorów ani parametrów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor jest konwertowany na nadpisaną wersję metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt;. Metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Finalize&lt;/strong&gt; nie można nadpisać bezpośrednio ani wywołać.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Zarządzanie zasobami&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa nie posiada zasobów zarządzanych i niezarządzanych to nie potrzebuje implementować interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; ani posiadać destruktora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa posiada tylko zasoby zarządzane to powinna implementować &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; ale nie potrzebuje destruktora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli klasa posiada zasoby niezarządzane to powinna implementować &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IDisposable&lt;/strong&gt; oraz destruktor w wypadku gdy metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; nie zostanie wywołana przez program.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; musi być zabezpieczona przed jej wielokrotnym wywołaniem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; powinna zwalniać zasoby zarządzane i niezarządzane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Destruktor powinien zwalniać tylko zasoby niezarządzane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Po zwolnieniu zasobów metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; powinna wywoływać &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;GC.SuppressFinalize&lt;/strong&gt; aby przeskoczyć kolejkę finalizacji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Deklaracja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;using&lt;/strong&gt; pozwala programowi na automatyczne wywoływanie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Dispose&lt;/strong&gt; po wykonaniu bloku kodu.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Sun, 01 Nov 2015 17:20:23 Z</pubDate>
      <a10:updated>2015-11-01T17:20:23Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1121</guid>
      <link>http://smsoft.pl/blog/iii-uzycie-typow-danych/</link>
      <title>III. Użycie typów danych</title>
      <description>&lt;h2&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 34px;"&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konwersja wartości z jednego typu danych do drugiego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Poszerzenie, zwężenie, ukryta i jawna konwersja typów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Rzutowanie typów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Manipulowanie ciągami znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Formatowanie wartości.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Konwersja pomiędzy typami&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wielokrotnie programy muszą konwertować wartości z jednego typu do drugiego. Przykładowo program do tworzenia wykresów używa funkcji &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Math.Sin&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Math.Cos&lt;/em&gt; do wyliczania wartości dla wykresu po czym używa obiektu klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Graphics&lt;/em&gt; i metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DrawLines&lt;/em&gt; do rysowania wykresu. Pierwsze dwie metody używają wartości typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double&lt;/strong&gt; natomiast trzecia reprezentuje punkty za pomocą typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;float&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt;. &lt;br /&gt;Konwersja między typami w języku C# może odbywać się na kilka różnych sposobów:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Poprzez rzutowanie (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;cast&lt;/strong&gt;)&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Poprzez użycie operatora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;as&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Poprzez parsowanie (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;parse&lt;/strong&gt;)&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Convert&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Użycie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.BitConverter&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Konwersja poszerzająca i zwężająca&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konwersja poszerzająca polega na zmianie typu źródłowego na typ o większym zakresie który na pewno może posiadać każdą wartość zapisaną w typie źródłowym. W przypadku konwersji zwężającej typ docelowy nie pomieści wszystkich wartości typu źródłowego. Przykładowo typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt; może pomieścić wartości z zakresu –2,147,483,648 i 2,147,483,647. Typ&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;short&lt;/strong&gt; może pomieścić wartości z zakresu –32,768 i 32,767. Konwersja z typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;short&lt;/strong&gt; do &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt; jest konwersją rozszerzającą, natomiast konwersja z typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt; do typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;short&lt;/strong&gt; jest konwersją zwężającą. &lt;br /&gt;Konwersja zwężająca może zakończyć się niepowodzeniem jeżeli wartość nie mieści się w zakresie typu docelowego konwersji. Domyślnie język C# nie zgłosi wyjątku w czasie konwersji zwężającej dla typów całkowitych lub zmiennoprzecinkowych. Dla liczb całkowitych wynik zostanie obcięty do najwyższej lub najniższej możliwej wartości. W przypadku liczb zmiennoprzecinkowych ustawiona zostanie wartość nieskończoności. &lt;br /&gt;Można wymusić wyrzucenie wyjątku przez C# na kilka sposobów. &lt;br /&gt;Dla typów całkowitych pierwszym z nich jest użycie bloku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;checked&lt;/strong&gt; np.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;checked&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; big = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1000000&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;short&lt;/span&gt; small = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;short&lt;/span&gt;)big;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Blok &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;checked&lt;/strong&gt; wyrzucie wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OverflowException&lt;/strong&gt; jeżeli konwersja się nie powiedzie. &lt;br /&gt;Drugim sposobem jest ustawienie pola &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Check For Arithmetic Overflow&lt;/strong&gt; w opcjach zaawansowanych budowania projektu. &lt;br /&gt;Dla typów zmiennoprzecinkowych trzeba jawnie sprawdzić czy wynik nie jest nieskończonością. Typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;float&lt;/strong&gt; posiada metody sprawdzające &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsInfinity&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NegativeInfinity&lt;/strong&gt;, oto przykład:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; big = -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1E40&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; small = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;)big;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;.IsInfinity(small)) &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; OverflowException();&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Konwersja jawna i niejawna&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konwersja niejawna (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;implicit&lt;/strong&gt;) polega na tym, że program automatycznie konwertuje wartość z jednego typu danych do innego bez żadnych dodatkowych instrukcji mówiących o tym, że ma dokonać konwersji. konwersja jawna (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;explicit&lt;/strong&gt;) używa dodatkowych operatorów lub metod jak np operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;cast&lt;/strong&gt; lub metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;parse&lt;/strong&gt; żeby jawnie powiedzieć programowi jak ma dokonać konwersji typów danych. &lt;br /&gt;Ponieważ konwersja zwężająca może prowadzić do utraty danych to C# nie wykonuje takiej konwersji automatycznie, więc nie pozwoli na niejawną konwersję zwężającą. Konwersja która może powodować utratę danych musi być deklarowana jawnie. &lt;br /&gt;Ponieważ konwersja rozszerzająca zawsze kończy się powodzeniem to program w C# może dokonywać jej niejawnie. &lt;br /&gt;Poniższy kod prezentuje przykłady konwersji jawnej i niejawnej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Narrowing conversion so explicit conversion is required.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; value1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; value2 = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;)value1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Widening conversion so implicit conversion is allowed.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; value3 = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;long&lt;/span&gt; value4 = value3;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dla typów referencyjnych konwersja do bezpośredniej lub pośredniej klasy przodka lub interfejsu jest konwersją rozszerzającą więc program może jej dokonać jawnie.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Rzutowanie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operator rzutowania mówi kompilatorowi bezpośrednio, że chcemy konwertować wartość do danego typu danych. Aby rzutować zmienną do określonego typu umieszczamy nazwę typu do którego chcemy konwertować w nawiasie okrągłym tuż przed zmienną do konwersji. Przykład wykorzystania operatora rzutowania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; value1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; value2 = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt;)value1;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operator rzutowania może prowadzić do obcięcia wartości np przy rzutowaniu wartości zmiennoprzecinkowej na typ całkowity. &lt;br /&gt;Ponieważ konwersja typów referencyjnych do bezpośredniej lub pośredniej klasy przodka lub interfejsu jest konwersją rozszerzającą to program może wykonywać ją niejawnie np. jeżeli klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Employee&lt;/span&gt; employee1 = new Employee();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Person&lt;/span&gt; person1 = employee1;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konwersja typów referencyjnych do bezpośredniej lub pośredniej klasy przodka lub interfejsu nie zmienia wartości zmiennej tylko jej typ. Konwersja z typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; do typu &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; jest konwersją zwężającą więc wymaga operatora rzutowania np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Employee employee1&lt;/span&gt; = new Employee();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Person person1&lt;/span&gt; = employee1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Person person2&lt;/span&gt; = new Employee();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Allowed because person1 is actually an Employee.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Employee employee2&lt;/span&gt; = (Employee)person1;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operator tego typu spowoduje, że dany kod się skompiluje, lecz jeżeli wartość nie jest aktualnie odpowiedniego typu to program zgłosi wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;InvalidCastException&lt;/strong&gt;. Przykładowo poniższy kod zgłosi wyjątek:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Person person2&lt;/span&gt; = new Person();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Not allowed because person2 is a Person but not an Employee.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;Employee employee3&lt;/span&gt; = (Employee)person2;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ programy często potrzebują konwersji pomiędzy kompatybilnymi typami referencyjnymi to C# umożliwia użycie dwóch operatorów które ułatwiają taką konwersję, są to operatory &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;is&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;as&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Operator “is”&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;is&lt;/strong&gt; określa czy obiekt jest zgodny z określonym typem. Poniższy kod sprawdza czy zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;user&lt;/em&gt; jest typu&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (user &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;is&lt;/span&gt; Employee)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do something with the Employee...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;is&lt;/strong&gt; zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli obiekt jest kompatybilny z typem tzn, że zwróci prawdę jeżeli obiekt &lt;em style="box-sizing: border-box; outline: none !important;"&gt;user&lt;/em&gt; jest typu który dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Operator “as”&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;as&lt;/strong&gt; służy do rzutowania typów. Wyrażenie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;object as Class&lt;/em&gt; zwraca obiekt skonwertowany na wyznaczoną klasę jeżeli obiekt ten jest kompatybilny z tą klasą. Jeżeli obiekt nie jest kompatybilny z klasą to rezultatem będzie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt; np.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;Employee emp = user &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;as&lt;/span&gt; Employee;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (emp != &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Do something with the Employee...&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jedną z sytuacji, w której operator &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;as&lt;/strong&gt; jest szczególnie przydatna jest sytuacja, gdy wiesz, że zmienna odnosi się do obiektu określonego typu np obsługa zdarzenia &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CheckedChanged&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Make the selected RadioButton red.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;MenuRadioButton_CheckedChanged&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    RadioButton rad = sender &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;as&lt;/span&gt; RadioButton;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (rad.Checked) rad.ForeColor = Color.Red;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt; rad.ForeColor = SystemColors.ControlText;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Rzutowanie tablic&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W przypadku rzutowania tablic obowiązują te same reguły co w przypadku rzutowania typów wartości i referencyjnych. Załużmy, że klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt; dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Person&lt;/em&gt; a klasa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Manager&lt;/em&gt; dziedziczy z klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt;. poniższy kod demonstruje reguły rzutowania tablic:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// Declare&lt;span style="box-sizing: border-box; outline: none !important;"&gt; and &lt;/span&gt;initialize an&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;of Employees.&lt;br /&gt;Employee&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;] employees =&lt;span style="box-sizing: border-box; outline: none !important;"&gt; new &lt;/span&gt;Employee&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;10];&lt;br /&gt;for&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; (&lt;/span&gt;int id = 0; id &amp;lt; employees.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Length;&lt;/span&gt; id++&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    employees&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;id] =&lt;span style="box-sizing: border-box; outline: none !important;"&gt; new &lt;/span&gt;Employee(id&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Implicit cast to an&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;of Persons.&lt;br /&gt;//&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; (&lt;/span&gt;An Employee is a type of Person.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;Person&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;] persons = employees;&lt;br /&gt;&lt;br /&gt;// Explicit cast back to an&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;of Employees.&lt;br /&gt;//&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; (&lt;/span&gt;The Persons in the&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;happen to be Employees.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;employees =&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; (&lt;/span&gt;Employee&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;]&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;persons;&lt;br /&gt;&lt;br /&gt;// Use the is operator.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;if &lt;/span&gt;(persons is Employee&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;]&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    // Treat them as Employees.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Use the as operator.&lt;br /&gt;employees = persons as Employee&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;// After this as statement, managers is null.&lt;br /&gt;Manager&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;] managers = persons as Manager&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;// Use the is operator again, this time to see&lt;br /&gt;//&lt;span style="box-sizing: border-box; outline: none !important;"&gt; if &lt;/span&gt;persons is compatible with Manager&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;].&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;if &lt;/span&gt;(persons is Manager&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;]&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    // Treat them as Managers.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// This cast fails at run time because the&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array&lt;br /&gt;&lt;/span&gt;// holds Employees&lt;span style="box-sizing: border-box; outline: none !important;"&gt; not &lt;/span&gt;Managers.&lt;br /&gt;managers =&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; (&lt;/span&gt;Manager&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;]&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;persons;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Rzutowanie nie tworzy nowej tablicy. Aby utworzyć kopię można użyć metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Array.Copy&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wiedząc, że tablica &lt;em style="box-sizing: border-box; outline: none !important;"&gt;persons&lt;/em&gt; jest aktualnie referencją do tablicy obiektów klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Employee&lt;/em&gt;, to jasne jest, że poniższe wyrażenie zgłosi wyjątek typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ArrayTypeMismatchException&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;persons[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Person(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Rzutowanie tablicy na nowy typ nie powoduje, że elementy tablicy stają się obiektami tego typu.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Konwertowanie wartości&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Rzutowanie pozwala na konwersję pomiędzy kompatybilnymi typami. Czasami jednak potrzebujemy konwersji pomiędzy typami które nie są ze sobą kompatybilne np tekstowy ciąg znaków “10” do typu całkowitego. W takim przypadku rzutowanie zawiedzie. &lt;br /&gt;Aby dokonać konwersji pomiędzy niekompatybilnymi typami trzeba użyć klas lub metod pomocniczych których dostarcza&lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt;, są to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Metody parsujące&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Convert&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.BitConverter&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metody parsujące&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Każdy z typów prostych języka C# posiada metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Parse&lt;/strong&gt; która konwertuje ciąg znaków do tego typu danych. Jeżeli wartość wejściowa jest w nierozpoznawalnym formacie to zgłoszony zostaje wyjątek np: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FormatException&lt;/strong&gt; w przypadku&lt;em style="box-sizing: border-box; outline: none !important;"&gt;bool.Parse(“yes”)&lt;/em&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OverflowException&lt;/strong&gt; jeżeli liczba jest z poza zakresy typu do którego jest konwertowana. &lt;br /&gt;Każda z klas posiada również metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TryParse&lt;/strong&gt; która zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; jeżeli konwersja się powiedzie i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;false&lt;/em&gt; w przeciwnym wypadku. Skonwertowana wartość zwracana jest jako zmienna wyjściowa którą wstawiono jako argument metody. &lt;br /&gt;Przykład parsowania wartości wprowadzonych do pola tekstowego na zmienną typu całkowitego:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; quantity;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    quantity = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;.Parse(quantityTextBox.Text);&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;catch&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    quantity = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; weight;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (!&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;.TryParse(weightTextBox.Text, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;out&lt;/span&gt; weight)) weight = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli to możliwe to zaleca się unikania parsowania ponieważ dla niektórych typów może być ono skomplikowane. &lt;br /&gt;Parsowanie daty i czasu działa dobrze jeżeli parsowany ciąg znaków jest dobrze sformatowany np dla j. angielskiego:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;DateTime.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Parse&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"3:45 PM April 1, 2014"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ToString&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;DateTime.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Parse&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"1 apr 2014 15:45"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ToString&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;DateTime.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Parse&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"15:45 4/1/14"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ToString&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;DateTime.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Parse&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"3:45pm 4.1.14"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ToString&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parsowanie walut w domyślny sposób jest skomplikowane. Symbol waluty nie jest domyślnie obsługiwany więc poniższa instrukcja zgłosi wyjątek &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SyntaxException&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt; amount = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;decimal&lt;/span&gt;.Parse(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"$123,456.78"&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można do metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;parse&lt;/em&gt; dodać kolejny parametr umożliwiający użycie symboli walut. Jego wartość jest kombinacją wartości zdefiniowanych w enumeratorze &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Globalization.NumberStyles&lt;/strong&gt;. &lt;br /&gt;Przykładowo &lt;em style="box-sizing: border-box; outline: none !important;"&gt;decimal.Parse&lt;/em&gt; używa domyślnie stylów pozwalających na użycie separatora dla tysięcy i liczb po przecinku. &lt;br /&gt;Przykład umożliwiający użycie symboli walut:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;decimal amount = decimal.Parse(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"$123,456.78"&lt;/span&gt;,&lt;br /&gt;    NumberStyles.AllowCurrencySymbol &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;|&lt;/span&gt;&lt;br /&gt;    NumberStyles.AllowThousands &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;|&lt;/span&gt;&lt;br /&gt;    NumberStyles.AllowDecimalPoint);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parsowanie uwzględnia również lokalizację i próbuje interpretować argumenty dla narodowości i języka w którym program jest uruchamiany. &lt;br /&gt;Przykładowo we Francji metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;int.Parse&lt;/em&gt; skonwertuje wartość “123 456,78” lecz zgłosi wyjątek dla “123.456,78.”. &lt;br /&gt;Wszystkie literały w języku C# powinny używać formatowania &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;U.S. English&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;System.Convert&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Convert&lt;/strong&gt; posiada ponad 300 metod służących do konwersji pomiędzy typami (wliczając metody przeciążone). Przykładowo metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Convert.ToInt32&lt;/strong&gt; konwertuje wartość do typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt;. Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToInt32&lt;/strong&gt; posiada przeciążone wersje przyjmujące jako argument różne typy danych. &lt;br /&gt;Metody konwertujące do typów całkowitych używają tzw “zaokrąglenia bankiera” co oznacza, że zaokrąglają wartość do najbliższej wartości całkowitej. Jeżeli wartość jest równo w połowie np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;0.5&lt;/em&gt; to zaokrąglenie odbywa się do najbliższej liczby parzystej (przykładowo &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ToInt16(9.5)&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ToInt16(10.5)&lt;/em&gt; zwrócą 10).&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Convert&lt;/strong&gt; posiada również metodę która konwertuje wartość do nowego typu ustalanego poprzez parametr w czasie wykonania np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;(int)Convert.ChangeType(5.5, typeof(int))&lt;/em&gt; zwróci 6.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;System.BitConverter&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.BitConverter&lt;/strong&gt; posiada metody pozwalające na konwersję do tablicy bajtowej i z tablicy bajtowej. Metoda&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Getbytes&lt;/strong&gt; zwraca tablicę bajtów reprezentującą wartość która została wprowadzona jako argument. Przykładowo jeżeli wstawimy wartość typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt; to zwrócona zostanie tablica zawierająca cztery bajty reprezentujące tą wartość. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.BitConverter&lt;/strong&gt; posiada również metody jak np &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToInt32&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToSingle&lt;/strong&gt; które konwertują wartości w tablicy bajtowej do żądanego typu danych.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Pakowanie i rozpakowywanie typów wartości (boxing and unboxing)&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pakowanie (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;boxing&lt;/em&gt;) jest procesem konwersji typów wartości do obiektu lub interfejsu który jest obsługiwany przez ten typ. Rozpakowywanie jest procesem odwrotnym. &lt;br /&gt;Przykładowo poniższy kod tworzy obiekt który odnosi się do wartości całkowitej:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Declare and initialize integer i.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Box i.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;object&lt;/span&gt; iObject = i;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;iObject&lt;/em&gt; jest obiektem który odnosi się do wartości 10. &lt;br /&gt;Pakowanie i rozpakowywanie zajmuje więcej czasu niż przypisanie jednej zmiennej typu wartości do innej więc powinno sie tego unikać jeżeli to możliwe. &lt;br /&gt;Zwykle pakowanie i rozpakowywanie jest wykonywane automatycznie. często dzieje się to gdy wywołujemy metodę która oczekuje jako parametru obiektu a otrzymuje wartość np.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1337&lt;/span&gt;;&lt;br /&gt;Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"i is: {0}"&lt;/span&gt;, i));&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dodatkowo pakowanie i rozpakowywanie posiada delikatny efekt uboczny który prowadzi do mylącego kodu np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Declare and initialize integer i.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Box i.&lt;/span&gt;&lt;br /&gt;object iObject = i;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Change the values.&lt;/span&gt;&lt;br /&gt;i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;;&lt;br /&gt;iObject = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display the values.&lt;/span&gt;&lt;br /&gt;Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(i);&lt;br /&gt;Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(iObject);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynikiem tego kodu będą liczby 1 i 2. Zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;iObject&lt;/em&gt; wydaje się być referencją do zmiennej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;i&lt;/em&gt; lecz tak naprawdę są to dwie różne wartości.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Zapewnienie interoperacyjności z kodem niezarządzalnym&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Interoperacyjność pozwala programowi w C3 na użycie klas udostępnionych przez kod niezarządzalny który nie został napisany pod kontrolą &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CLR&lt;/strong&gt; (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Common Language Runtime&lt;/em&gt;). Przykładami kodu niezarządzanego są &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ActiveX&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Win32 API&lt;/em&gt;. &lt;br /&gt;Dwoma najpopularniejszymi technikami pozwalającymi na używanie kodu niezażądzanego są &lt;em style="box-sizing: border-box; outline: none !important;"&gt;COM Interop&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Platform invoke (P/invoke)&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;P/invoke&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Aby użyć kodu niezarządzanego z poziomu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;P/invoke&lt;/strong&gt; należy załączyć atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DllImport&lt;/strong&gt; z przestrzeni nazw&lt;em style="box-sizing: border-box; outline: none !important;"&gt;System.Runtime.InteropServices&lt;/em&gt; który definiuje niezarządzane metody które będą używane przez zarządzany program. &lt;br /&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DllImport&lt;/strong&gt; przyjmuje parametry które mówią o cechach metod niezarządzanych. parametry te zawierają nazwę biblioteki &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DLL&lt;/em&gt;która zawiera metodę, zestaw znaków używanych przez metodę (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Unicode&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ANSI&lt;/em&gt;) i punkt wejścia w &lt;em style="box-sizing: border-box; outline: none !important;"&gt;DLL&lt;/em&gt; używany przez metodę. &lt;br /&gt;Program stosuje atrybut jako deklarację metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;static extern&lt;/em&gt;. Deklaracja zawiera parametry których używa metoda oraz zwracany typ. Deklaracja ta powinna znajdować się w klasie. Przykład użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DllImport&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System.Runtime.InteropServices;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;namespace&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ShortPathNames&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;partial&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Form1&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;            InitializeComponent();&lt;br /&gt;        }&lt;br /&gt;        [DllImport(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"kernel32.dll"&lt;/span&gt;, CharSet = CharSet.Auto, SetLastError = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;extern&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;uint&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;GetShortPathName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; lpszLongPath, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;char&lt;/span&gt;[] lpszShortPath, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; cchBuffer)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Get the long file name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; longName = fileTextBox.Text;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Allocate a buffer to hold the result.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;[] buffer = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1024&lt;/span&gt;];&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;long&lt;/span&gt; length = GetShortPathName(longName, buffer, buffer.Length);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Get the short name.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; shortName = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt;(buffer);&lt;br /&gt;        shortNameTextBox.Text = shortName.Substring(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;, (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;)length);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Do lepszej kontroli konwersji wartości pomiędzy kodem zarządzanym i niezarządzanym służy atrybut &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;MarshalAs&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;DllImport&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"kernel32.dll"&lt;/span&gt;, CharSet = CharSet.Auto, SetLastError=true)&lt;/span&gt;]&lt;br /&gt;static extern uint GetShortPathName&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;MarshalAs&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;UnmanagedType.LPTStr&lt;/span&gt;)&lt;/span&gt;] string lpszLongPath,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;MarshalAs&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;UnmanagedType.LPTStr&lt;/span&gt;)&lt;/span&gt;] StringBuilder lpszShortPath,&lt;br /&gt;    uint cchBuffer)&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Typy dynamiczne i COM Interop&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;COM Interop&lt;/strong&gt; umożliwia inny sposób współpracy kodu zarządzanego z niezarządzanym. Aby użyć &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;COM Interop&lt;/strong&gt; należy dodać referencję do odpowiedniej biblioteki poprzez zakładkę &lt;em style="box-sizing: border-box; outline: none !important;"&gt;COM&lt;/em&gt; w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Visual Studio&lt;/em&gt;. Dodanie referencji mówi programowi wiele o kodzie niezarządzanym, możemy np podejrzeć obiekty biblioteki w oknie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Object Browser&lt;/em&gt; i mamy dostęp do niektórych komponentów biblioteki z &lt;em style="box-sizing: border-box; outline: none !important;"&gt;IntelliSense&lt;/em&gt;. Niestety nie wszystkie typy biblioteki są zawsze rozpoznawane. &lt;br /&gt;Od wersji 4.0 języka C# wprowadzony został specjalny typ danych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;dynamic&lt;/strong&gt; którego można użyć w takich sytuacjach. Jest to statyczny typ danych, lecz jego prawdziwy typ jest wyznaczany w czasie uruchomienia. W czasie kompilacji typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;dynamic&lt;/strong&gt;nie jest sprawdzany i nie zwraca błędów składni ani niedopasowania typów. &lt;br /&gt;C# uznaje obiekty zdefiniowane przez kod niezarządzany &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;COM&lt;/strong&gt; jako typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;dynamic&lt;/strong&gt;. &lt;br /&gt;Przykład użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;dynamic&lt;/strong&gt; i biblioteki &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft.Office.Interop.Excel&lt;/em&gt; jako biblioteki &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;COM Interop&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Open the Excel application.&lt;/span&gt;&lt;br /&gt;Excel._Application excelApp = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Excel.Application();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Add a workbook.&lt;/span&gt;&lt;br /&gt;Excel.Workbook workbook = excelApp.Workbooks.Add();&lt;br /&gt;Excel.Worksheet sheet = workbook.Worksheets[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;];&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display Excel.&lt;/span&gt;&lt;br /&gt;excelApp.Visible = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display some column headers.&lt;/span&gt;&lt;br /&gt;sheet.Cells[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;].Value = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Value"&lt;/span&gt;;&lt;br /&gt;sheet.Cells[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;].Value = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Value Squared"&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Display the first 10 squares.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; i &amp;lt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;; i++)&lt;br /&gt;{&lt;br /&gt;    sheet.Cells[i + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;].Value = i;&lt;br /&gt;    sheet.Cells[i + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;].Value = (i * i).ToString();&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Autofit the columns.&lt;/span&gt;&lt;br /&gt;sheet.Columns[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;].AutoFit();&lt;br /&gt;sheet.Columns[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;].AutoFit();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład bardziej specyficznego dla języka C# kodu wykorzystującego typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;dynamic&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Make an array of numbers.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;[] array1 = { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt; };&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// This doesn't work because array1.Clone is an object.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//int[] array2 = array1.Clone();&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// This works.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;[] array3 = (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt;[])array1.Clone();&lt;br /&gt;array3[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;55&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// This also works.&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;dynamic&lt;/span&gt; array4 = array1.Clone();&lt;br /&gt;array4[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;66&lt;/span&gt;;&lt;br /&gt;array4[&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;] = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This won't work"&lt;/span&gt;;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Manipulowanie ciągami znaków&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Typ danych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; jest inny niż wszystkie inne typy. Programy traktują je zwykle jak inne typy wartości ale klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; jest bardzo skomplikowana. Typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string&lt;/strong&gt; jest aliasem dla klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.String&lt;/strong&gt;. &lt;br /&gt;W &lt;em style="box-sizing: border-box; outline: none !important;"&gt;.NET Framework&lt;/em&gt; znaki reprezentowane są jako &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Unicode&lt;/em&gt; w wersji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;UTF-16&lt;/strong&gt;. Format ten zapisuje każdy znak jako 16 bitów. Typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; jest obiektem który używa ciągu znaków do zapisania jakiegoś tekstu. Cechą typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string&lt;/strong&gt; jest to że jego wartości są niezmienne (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;immutable&lt;/em&gt;). Oznacza to, że treść ciągu znaków zapisanych jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; nie może być zmieniona po utworzeniu obiektu. Zamiast tego metody modyfikujące ciągi znaków jak np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Replace&lt;/em&gt; zwracają nowy obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;zawierający zmodyfikowaną wartość. &lt;br /&gt;W celu oszczędzania pamięci &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CLR&lt;/strong&gt; utrzymuje tablicę o nazwie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;intern pool&lt;/em&gt; która przetrzymuje pojedynczą referencję do każdego unikalnego tekstu używanego przez program. Każda zmienna typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; odwołująca się do jakiegoś fragmentu tekstu jest referencją do &lt;em style="box-sizing: border-box; outline: none !important;"&gt;intern pool&lt;/em&gt;. &lt;br /&gt;Wymaga to pewnego narzutu obliczeniowego dlatego praca z ciągami znaków nie jest tak szybka jak z typami wartości. Jeżeli program musi dokonać wielu scaleń tekstów a każde tworzy nowy obiekt &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; to w rezultacie zajmuje to dużo czasu. W takim przypadku użycie klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt; może poprawić wydajność.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Konstruktory klasy String&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Trzy najbardziej znane metody inicjalizujące zmienną typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; to:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;ustawienie jako literału.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;ustawienie jako tekstu wpisanego do kontrolki użytkownika.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;ustawienie jako wyniku operacji na tekście. &lt;br /&gt;Ostatnia z metod zawiera metody formatujące zmienne jako ciąg znaków np za pomocą metody &lt;em style="box-sizing: border-box; outline: none !important;"&gt;ToString&lt;/em&gt; lub&lt;em style="box-sizing: border-box; outline: none !important;"&gt;String.Format&lt;/em&gt;. &lt;br /&gt;Oprócz tych metod, klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; posiada kilka konstruktorów które mogą być czasami użyteczne:&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konstruktor inicjalizujący obiekt z tablicy znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konstruktor inicjalizujący obiekt z części tablicy znaków, pobierający dodatkowe parametry startowej pozycji w tablicy i długości ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konstruktor pobierający znak i liczbę powtórzeń tego znaku.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Właściwości i pola klasy String&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; posiada trzy pola i właściwości: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Empty&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Length&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;indexer&lt;/strong&gt; który jest tylko do odczytu. &lt;br /&gt;Pole &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Empty&lt;/strong&gt; zwraca obiekt reprezentujący pusty ciąg znaków równy literałowi “”. &lt;br /&gt;Właściwość &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Length&lt;/strong&gt; zwraca długość ciągu znaków. &lt;br /&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Indexer&lt;/strong&gt; który jest tylko do odczytu zwraca znaki typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;char&lt;/strong&gt; ciągu typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string&lt;/strong&gt;. Dzięki temu możemy odczytać znak który jest na konkretnej pozycji ciągu.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Metody klasy String&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Większość przydatnych statycznych metod klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Compare&lt;/strong&gt; - Porównuje dwa ciągi znaków i zwraca -1, 0 lub 1 co oznacza, że pierwszy porównywany ciąg jest przed drugim, jest równy lub jest za drugim ciągiem w kolejności alfabetycznej. Metody przeciążone pozwalają na ustanowienie zasad porównywania i wybór języka porównywania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Concat&lt;/strong&gt; - Scala ciągi znaków podane na wejściu jako tablica lub w metodzie przeciążonej jako wiele argumentów typu&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;string&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Copy&lt;/strong&gt; - zwraca kopię ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Equals&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli ciągi są takie same.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Format&lt;/strong&gt; - używana do generowania sformatowanego tekstu. Przyjmuje jako parametry listę ciągów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNullOrEmpty&lt;/strong&gt; - sprawdza czy wartość ciągu jest pusta lub równa &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IsNullOrWhiteSpace&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli ciąg jest pusty, równy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;null&lt;/em&gt; lub zawiera białe znaki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Join&lt;/strong&gt; - złącza ciągi tablicy oddzielając je w docelowym ciągu znakiem separacji podawanym jako pierwszy parametr wejściowy.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Większość przydatnych metod instancji klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Clone&lt;/strong&gt; - zwraca nową referencję do obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CompareTo&lt;/strong&gt; - porównuje ciąg z innym i zwraca -1 jeżeli jest przed, 0 jeżeli jest równy i 1 jeżeli jest za w kolejności alfabetycznej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Contains&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli ciąg zawiera wybrany podciąg.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;CopyTo&lt;/strong&gt; - kopiuje wybraną ilość znaków od wybranej pozycji początkowej do tablicy znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EndsWith&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli ciąg zakończony jest wybranym podciągiem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Equals&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli ciąg jest równy innemu ciągowi.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IndexOf&lt;/strong&gt; - zwraca indeks pierwszego wystąpienia znaku lub podciągu w ciągu. Parametry pozwalają także zdefiniować pozycję startową i końcową przeszukiwania oraz opcje porównywania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;LastIndexOf&lt;/strong&gt; - zwraca indeks ostatniego wystąpienia znaku lub podciągu w ciągu. Parametry pozwalają także zdefiniować pozycję startową i końcową przeszukiwania oraz opcje porównywania.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Insert&lt;/strong&gt; - wstawia ciąg na wyznaczonej pozycji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PadLeft&lt;/strong&gt; - zwraca ciąg wypełniony z lewej strony wybraną liczbą wyspecyfikowanych znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;PadRight&lt;/strong&gt; - zwraca ciąg wypełniony z prawej strony wybraną liczbą wyspecyfikowanych znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Remove&lt;/strong&gt; - usuwa znaki od wyznaczonej pozycji początkowej do wyznaczonej pozycji końcowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Replace&lt;/strong&gt; - zamienia wszystkie wystąpienia znaku lub podciągu na inny znak lub ciąg.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Split&lt;/strong&gt; - rozdziela ciąg znaków na podciągi oddzielane wyznaczonymi znakami rozdzielającymi i zwraca tablicę podciągów.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StartWith&lt;/strong&gt; - zwraca &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; jeżeli ciąg zaczyna się od wybranego podciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Substring&lt;/strong&gt; - zwraca podciąg zaczynający się w wyznaczonej pozycji i posiadający wyznaczoną ilość znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToCharArray&lt;/strong&gt; - zwraca tablicę znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToLower&lt;/strong&gt; - zwraca kopię ciągu skonwertowana na małe znaki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToUpper&lt;/strong&gt; - zwraca kopię ciągu skonwertowana na duże znaki.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Trim&lt;/strong&gt; - zwraca kopię ciągu z usuniętymi białymi znakami na początku i na końcu ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TrimEnd&lt;/strong&gt; - zwraca kopię ciągu z usuniętymi białymi znakami na końcu ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TrimStart&lt;/strong&gt; - zwraca kopię ciągu z usuniętymi białymi znakami na początku ciągu.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Klasy obsługujące ciągi znaków&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Niezwykły sposób w jaki ciągi znaków są przechowywane czyni je niewydajnymi w pewnych zastosowaniach. Dla niektórych zastosowań programy mogą być bardziej wydajne używając innych klas operujących na ciągach znaków niż klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;StringBuider&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt; reprezentuje zmienną klasę ciągu znaków. Przechowuje dane znaków w tablicy do której można dodawać, usuwać i zamieniać znaki bez potrzeby tworzenia nowego obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; i użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;intern pool&lt;/strong&gt;. &lt;br /&gt;Zwykle programy używają klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt; do budowania ciągu znaków wykonywanego w wielu krokach po czym używają metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; która konwertuje ciąg znaków na typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;[]&lt;/span&gt; employeeNames =&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Able"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Baker"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Charley"&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Davis"&lt;/span&gt;,&lt;br /&gt;};&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StringBuilder&lt;/span&gt; allNames = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;StringBuilder&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;br /&gt;foreach (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; name &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; employeeNames)&lt;br /&gt;{&lt;br /&gt;    allNames.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Append&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"["&lt;/span&gt; + name + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"]"&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Environment&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;NewLine&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;employeeTextBox.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Text&lt;/span&gt; = allNames.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;ToString&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;()&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najbardziej użyteczne właściwości klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Capacity&lt;/strong&gt; - pobiera lub ustawia liczbę znaków, które mogą być przechowywane przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt;. Można użyć tej właściwości do alokacji pamięci potrzebnej dla operacji na ciągu zamiast pozwolić programowi na inkrementację pamięci kiedy jest to potrzebne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Length&lt;/strong&gt; - pobiera lub ustawia liczbę znaków przechowywane przez &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt;. Ustawienie mniejszej ilości niż rzeczywista prowadzi do obcięcia ciągu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najbardziej użyteczne metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Append&lt;/strong&gt; - dodaje ciąg znaków na koniec ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AppendFormat&lt;/strong&gt; - formatuje listę obiektów i dodaje ich znakową reprezentacje na końcu ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;EnsureCapacity&lt;/strong&gt; - sprawdza czy obiekt ma wystarczającą pojemność.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Insert&lt;/strong&gt; - wstawia ciąg znaków na wybraną pozycję ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Remove&lt;/strong&gt; - usuwa zakres znaków z ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Replace&lt;/strong&gt; - zamienia wszystkie wystąpienia znaku lub podciągu nowym znakiem lub podciągiem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; - zwraca ciąg znaków skonwertowanych do typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;StringWriter&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringWriter&lt;/strong&gt; w pewnych przypadkach pozwala na łatwiejsze budowanie ciągów znaków niż &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stringbuilder&lt;/strong&gt;. posiada metody które ułatwiają sekwencyjne zapisywanie wartości do ciągu znaków. &lt;br /&gt;Przydatne metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringWriter&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Flush&lt;/strong&gt; - opróżnia wszystkie buforowane dane do obiektu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringWriter&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; - zwraca ciąg znaków skonwertowanych do typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Write&lt;/strong&gt; - dołącza obiekt do ciągu znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteAsync&lt;/strong&gt; - asynchronicznie dołącza znak, ciąg lub tablicę znaków na koniec ciągu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WriteLine&lt;/strong&gt; - dołącza obiekt do ciągu znaków po czym dodaje znak nowej linii. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringWriter&lt;/strong&gt; jest użyteczna kiedy wykonujemy tylko dołączanie wartości do ciągu znaków. Implementuje także interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriter&lt;/strong&gt;, więc może być użyteczna kiedy inna klasa używa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriter&lt;/strong&gt;. Przykładowo metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Serialize&lt;/strong&gt;klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XmlSerializer&lt;/strong&gt; zwraca wynik w postaci &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextWriter&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;StringReader&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt; jest implementacją interfejsu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;TextReader&lt;/strong&gt; która czyta fragmenty danych pobranych z klasy&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Stringbuilder&lt;/strong&gt;. Posiada metody które ułatwiają sekwencyjne czytanie fragmentów tekstu ciągu znaków. &lt;br /&gt;Przydatne metody klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt;:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Peek&lt;/strong&gt; - zwraca następny znak z danych ale nie przechodzi do tego znaku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Read&lt;/strong&gt; - zwraca następny znak z danych i przechodzi do tego znaku. metoda przeciążona może czytać blok znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadAsync&lt;/strong&gt; - asynchronicznie czyta znaki do bufora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadBlock&lt;/strong&gt; - wczytuje maksymalną liczbę znaków do bufora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadBlockAsync&lt;/strong&gt; - asynchronicznie wczytuje maksymalną liczbę znaków do bufora.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadLine&lt;/strong&gt; - wczytuje znaki do napotkania końca linii.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadLineAsync&lt;/strong&gt; - asynchronicznie wczytuje znaki do napotkania końca linii.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadToEnd&lt;/strong&gt; - zwraca pozostały tekst jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ReadToEndAsync&lt;/strong&gt; - asynchronicznie zwraca pozostały tekst jako &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt;. &lt;br /&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringReader&lt;/strong&gt; dostarcza dostępu do danych klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;StringBuilder&lt;/strong&gt; na relatywnie niskim poziomie. Programy często wykorzystują tę klasę ponieważ inna metoda wymaga użycia tego typu.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Formatowanie wartości&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Formatowanie wartości tak aby była poprawnie wyświetlana jest szczególnie ważnym typem konwersji. Typy danych takie jak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DateTime&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;decimal&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double&lt;/strong&gt; nie mogą być wyświetlone użytkownikowi bez wcześniejszej konwersji do czytelnego formatu. &lt;br /&gt;Dwie najczęściej używane metody formatowania wartości jako ciągu znaków to metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String.Format&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;ToSting&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Klasa &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Object&lt;/strong&gt; wprowadza metodę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; która jest dziedziczona przez każdą inną klasę. Domyślnie metoda ta zwraca nazwę typu obiektu jako ciąg znaków typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String&lt;/strong&gt; ale większość klas nadpisuje tą metodę tak aby zwracała wartość obiektu jako ciąg znaków. &lt;br /&gt;Przykładowo metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; dla zmiennej typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;float&lt;/strong&gt; o wartości &lt;em style="box-sizing: border-box; outline: none !important;"&gt;1.23&lt;/em&gt; zwróci ciąg znaków równy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“1.23”&lt;/em&gt;. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; może posiadać także parametry &lt;em style="box-sizing: border-box; outline: none !important;"&gt;format provider&lt;/em&gt; i &lt;em style="box-sizing: border-box; outline: none !important;"&gt;formatting string&lt;/em&gt;. Ciąg formatujący pozwala na dostosowanie tekstu wynikowego. Przykładowo zmienna &lt;em style="box-sizing: border-box; outline: none !important;"&gt;cost&lt;/em&gt; typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;float&lt;/strong&gt; i metoda &lt;em style="box-sizing: border-box; outline: none !important;"&gt;cost.ToString(“0.00”)&lt;/em&gt; zwróci ciąg znaków z dwoma miejscami po przecinku.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;String.Format&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String.Format&lt;/strong&gt; pozwala budować ciąg znaków zwierający wartości z wielu zmiennych formatowanych w różny sposób. &lt;br /&gt;Metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String.Format&lt;/strong&gt; posiada kilka przeciążonych wersji, ale najczęściej używana jest z ciągiem formatującym i listą argumentów użytych aby wypełnić ciąg formatujący. &lt;br /&gt;Każdy element w ciągu formatującym posiada następującą składnię:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;{index[&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;,length&lt;/span&gt;][&lt;span style="box-sizing: border-box; outline: none !important;"&gt;:formatString&lt;/span&gt;]}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Index&lt;/em&gt; jest rozpoczynającym się od 0 numerem parametru który ma być użyty w ciągu wynikowym, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;length&lt;/em&gt; jest minimalną długością elementu a &lt;em style="box-sizing: border-box; outline: none !important;"&gt;formatString&lt;/em&gt; jestformatem ciągu. jeżeli &lt;em style="box-sizing: border-box; outline: none !important;"&gt;length&lt;/em&gt; jest wartością ujemną to wartość jest wyrównywana do lewej strony. Przykład użycia:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;163&lt;/span&gt;;&lt;br /&gt;Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{0} = {1,4} or 0x{2:X}"&lt;/span&gt;, (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;)i, i, i));&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ciąg formatujący “&lt;em style="box-sizing: border-box; outline: none !important;"&gt;{0} = {1,4} or 0x{2:X}&lt;/em&gt;” ma trzy elementy:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;{0} - wyświetla argument z indeksem 0 w domyślnym formacie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;{1,4} - wyświetla argument z indeksem 1 o szerokości co najmniej czterech znaków.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;{2:x} - wyświetla argument z indeksem 2 w formacie X (wyświetla liczbę całkowitą jako szesnastkową). &lt;br /&gt;Wynikiem działania jest: &lt;em style="box-sizing: border-box; outline: none !important;"&gt;£ = 163 or 0xA3&lt;/em&gt;. &lt;br /&gt;Argumenty nie muszą być użyte w formatowanym ciągu oraz mogą być używane w dowolnej kolejności lub wielokrotnie. poniższe wyrażenie jest poprawne:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;text&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;.Format(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"{1} {4} {2} {1} {3}"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"who"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"I"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"therefore"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"am"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"think"&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Ciągi formatujące&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ciągi formatujące dzielą się na dwie kategorie:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Standardowe - pozwalają określić, jak chcesz wyświetlaną wartość na wysokim poziomie. Standardowe ciągi formatujące są zależne od lokalizacji. Przykładowo format daty &lt;em style="box-sizing: border-box; outline: none !important;"&gt;“d”&lt;/em&gt; oznacza krótki wzorzec daty podobny do “3/14/2014” dla Stanów Zjednoczonych lub “14/03/2014” dla Francji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Niestandardowe - pozwalają na budowę formatu którego brakuje na liście standardowych formatów. &lt;br /&gt;Obie metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToString&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;String.Format&lt;/strong&gt; rozumieją setki standardowych i niestandardowych formatów. &lt;br /&gt;Standardowe numeryczne ciągi formatujące:&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;C&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;c&lt;/strong&gt; - waluta (currency) np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;$12,345.67&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;D&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;d&lt;/strong&gt; - format dziesiętny (decimal - tylko typy całkowite) np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;12345&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;E&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;e&lt;/strong&gt; - notacja naukowa np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;1.234567E+004&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;F&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;f&lt;/strong&gt; - format zmiennoprzecinkowy np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;12345.67&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;G&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;g&lt;/strong&gt; - format ogólny (naukowy lub zmiennoprzecinkowy) np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;12345.67&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;N&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;n&lt;/strong&gt; - numer (number - z separatorami) np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;12,345.67&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;P&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;p&lt;/strong&gt; - procent (pomnożony przez 100 i dodany znak “%” na końcu) np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;12.00 %&lt;/em&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;X&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;x&lt;/strong&gt; - szesnastkowy (tylko typy całkowite) np &lt;em style="box-sizing: border-box; outline: none !important;"&gt;3039&lt;/em&gt;&lt;br /&gt;Niektóre z formatów mogą posiadać opcjonalnie precyzję oznaczającą liczbę znaków po przecinku. jeżeli zmienna&lt;em style="box-sizing: border-box; outline: none !important;"&gt;value&lt;/em&gt; jest równa 12345.67 to &lt;em style="box-sizing: border-box; outline: none !important;"&gt;value.ToString(“C4”)&lt;/em&gt; zwróci “$12,345.6700”.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Standardowe ciągi formatujące daty i czasu:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;d&lt;/strong&gt; - krótka data np “3/14/2014”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;D&lt;/strong&gt; - długa data np “Friday, March 14, 2012”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;f&lt;/strong&gt; - długa data z krótkim czasem np “Friday, March 14, 2012 2:15 PM”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;F&lt;/strong&gt; - długa data z długim czasem np “Friday, March 14, 2012 2:15:16 PM”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;g&lt;/strong&gt; - ogólna data z krótkim czasem np “3/14/2014 2:15 PM”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;G&lt;/strong&gt; - ogólna data z długim czasem np “3/14/2014 2:15:16 PM”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;m&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;M&lt;/strong&gt; - Miesiąc/dzień np “March 14”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;t&lt;/strong&gt; - krótki czas np “2:15 PM”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T&lt;/strong&gt; - długi czas np “2:15:16 PM”&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;y&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Y&lt;/strong&gt; - Rok/miesiąc np “March, 2014” &lt;br /&gt;Dodatkowo struktura &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DateTime&lt;/strong&gt; posiada metody zwracające datę w formatach &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;d&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;D&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;t&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T&lt;/strong&gt;. Są to metody&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToShortDateString&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToLongDateString&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToShortTimeString&lt;/strong&gt;, i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ToLongTimeString&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 22 Oct 2015 21:23:57 Z</pubDate>
      <a10:updated>2015-10-22T21:23:57Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1120</guid>
      <link>http://smsoft.pl/blog/ii-praca-z-typami-danych/</link>
      <title>II. Praca z typami danych</title>
      <description>&lt;h1&gt;Zagadnienia egzaminu 70-483 opisane w tej notatce:&lt;/h1&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;tworzenie typów wartości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;value types&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;tworzenie typów referencyjnych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;reference types&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;tworzenie typów generycznych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;generic types&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;konstruktory &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;constructors&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;metody &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;methods&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;klasy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;classes&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;metody rozszerzające &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;extension methods&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;parametry nazwane i opcjonalne &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;optional and named parameters&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;właściwości indeksowane &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;indexed properties&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;metody przeciążone &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;overloaded methods&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;metody przesłonięte &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;overriden methods&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;enkapsulacja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;encapsulation&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;właściwości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;properties&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;metody dostępowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;accessor methods&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Typy wartości&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Typy wartości w C# dzielą się na dwie główne kategorie nazywane strukturami i wyliczeniami (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;structs and enumerations&lt;/strong&gt;). Struktury dzielą się na typy numeryczne (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;numeric types&lt;/strong&gt;: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;integral types&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;floating-point types&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;decimals&lt;/strong&gt;), typy logiczne (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool&lt;/strong&gt;) i struktury zdefiniowane przez użytkownika (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;user-defined structs&lt;/strong&gt;). Enumeratory są zbiorami typów deklarowanymi za pomocą słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;enum&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Predefiniowane typy wartości&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie typy wartości dziedziczą z &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.ValueType&lt;/strong&gt;. typy wartości posiadają aliasy służące do łatwiejszej deklaracji typów. Poniższa tabela zawiera typy danych wartości języka C#:&lt;/p&gt;
&lt;table border="0" style="box-sizing: border-box; outline: none !important; max-width: 100%; border-collapse: collapse; border-spacing: 0px; margin-bottom: 20px; background-color: transparent;"&gt;
&lt;thead&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;th align="left" style="box-sizing: border-box; outline: none !important; text-align: left; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Typ (alias)&lt;/th&gt;
&lt;th align="right" style="box-sizing: border-box; outline: none !important; text-align: right; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Wartości&lt;/th&gt;
&lt;th align="center" style="box-sizing: border-box; outline: none !important; text-align: center; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Rozmiar&lt;/th&gt;
&lt;th align="center" style="box-sizing: border-box; outline: none !important; text-align: center; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Typ .NET&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;true, false&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;1 byte&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Boolean&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Byte&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;0–255&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;1 byte&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Byte&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;char&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;0000–FFFF Unicode&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;16-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Char&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;decimal&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;±1.0 × 10^−28 to ±7.9 × 10^28&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;28–29&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;significant digits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;double&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;±5.0 × 10^−324 to ±1.7 × 10^308&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;15–16 digits&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Double&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;enum&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;User-defined set of name constants&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt; &lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;float&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;±1.5 × 10^−45 to ±3.4 × 10^38&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;7 digits&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Single&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;–2,147,483,648 to 2,147,483,647&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Signed 32-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Int32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;long&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;9,223,372,036,854,775,808 to 9,223,372,036,854,775,807&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Signed 64-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Int64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;sbyte&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;–128 to 127&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Signed 8-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.SByte&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;short&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;–32,768 to 32,767&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Signed 16-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Int16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;struct&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Includes the numeric types listed in this table as well as bool and user-defined structs&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt; &lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;uint&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;0 to 4,294,967,295&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Unsigned 32-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.UInt32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ulong&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;0 to 18,446,744,073,709,551,615&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Unsigned 64-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.UInt64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ushort&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;0 to 65,535&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Unsigned 16-bit&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;System.Uint16&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pracując z typami deklarujemy zmienne tak aby konkretnego typu. Po deklaracji zmiennej możemy przypisać jej wartość. Przypisanie może być również częścią deklaracji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;declare&lt;/span&gt; an &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;integer&lt;/span&gt; variable&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; myInt;&lt;/span&gt;&lt;br /&gt;// and assign a value to it&lt;br /&gt;myInt = 3;&lt;br /&gt;// &lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;use&lt;/span&gt; declaration &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;and&lt;/span&gt; assignment &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; one statement&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;int&lt;/span&gt; mySecondInt = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;50&lt;/span&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Słowo kluczowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;int&lt;/strong&gt; jest aliasem i oznacza, że deklarujemy zmienną typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;System.Int32&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Typy wartości posiadają pewne ograniczenia:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie można utworzyć nowego typu dziedziczącego z typu wartości.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;typy wartości nie mogą zawierać wartości &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;NULL&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowy program: &lt;br /&gt;using System;&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create a variable to hold a value type using the alias form&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// but don't assign a variable&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; myInt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; myNewInt = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create a variable to hold a .NET value type&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// this type is the .NET version of the alias form int&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// note the use of the keyword new, we are creating an object from&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// the System.Int32 class&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;var&lt;/span&gt; myInt32 = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; System.Int32();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// you will need to comment out this first Console.WriteLine statement&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// as Visual Studio will generate an error about using an unassigned&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// variable. This is to prevent using a value that was stored in the&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// memory location prior to the creation of this variable&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(myInt);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// print out the default value assigned to an int variable&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// that had no value assigned previously&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(myNewInt);&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// this statement will work fine and will print out the default value for&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// this type, which in this case is 0&lt;/span&gt;&lt;br /&gt;        Console.WriteLine(myInt32);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET Framework&lt;/strong&gt; dostarcza domyślnych wartości dla typów wartości. Dla wszystkich typów numerycznych jest to ekwiwalent zera dla danego typu (0). Dla typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;bool&lt;/strong&gt; domyślną wartością jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;false&lt;/strong&gt;, dla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;char&lt;/strong&gt; jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;‘\0’&lt;/strong&gt;, dla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;enum&lt;/strong&gt; jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;(E)0&lt;/strong&gt; a dla&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;struct&lt;/strong&gt; jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;null&lt;/strong&gt;.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET Framework&lt;/strong&gt; przechowuje typy wartości na stosie w pamięci komputera. rezultatem tego jest to, że gdy przypiszemy typ wartości do innego to jego wartość zostanie skopiowana.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Struktury&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Struktury lub po prostu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;struct&lt;/strong&gt;, są typami wartości których można użyć do przechowywania zbiorów wartości. Maja pewne cechy wspólne z klasami, lecz mają także pewne ograniczenia. &lt;br /&gt;Język C# umożliwia użycie wielu mechanizmów do przechowywania zbiorów danych jak struktury, klasy, tablice, kolekcje itd. Każda z nich ma swoje wymagania i ograniczenia które dyktują jak lub gdzie używać każdej z nich. &lt;br /&gt;Struktur używa się przeważnie dla definicji typów zawierających kilka związanych ze sobą elementów danych, te elementy danych są reprezentowane przez pola takiej struktury. Przykład deklaracji struktury opisującej studenta:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;struct&lt;/span&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; lastname;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt; initial;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; score1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; score2;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; score3;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; score4;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; score5;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; average;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Struktura zawiera zbiór właściwości reprezentowanych poprzez zmienne typu wartości. Sama struktura też jest typem wartości lecz typem złożonym. &lt;br /&gt;Przykład utworzenia instancji struktury:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create a new instance of the Student struct in code&lt;/span&gt;&lt;br /&gt;Student myStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create a new instance of the Student struct without the new keyword&lt;/span&gt;&lt;br /&gt;Student myOtherStudent;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Prosty przykład deklaracji, przypisania wartości do zmiennych i użycia struktury:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create a new instance of the Student struct&lt;/span&gt;&lt;br /&gt;Student myStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// assign some values to the properties of myStudent&lt;/span&gt;&lt;br /&gt;myStudent.firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fred"&lt;/span&gt;;&lt;br /&gt;myStudent.lastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Jones"&lt;/span&gt;;&lt;br /&gt;myStudent.score1 = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;89&lt;/span&gt;;&lt;br /&gt;myStudent.score2 = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;95&lt;/span&gt;;&lt;br /&gt;Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Student "&lt;/span&gt; + myStudent.firstName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + myStudent.lastName);&lt;br /&gt;Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Write&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" scored "&lt;/span&gt; + myStudent.score1 + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" on his/her first test. "&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// illegal statement, cannot use the type directly&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Visual Studio will indicate that an object reference is required&lt;/span&gt;&lt;br /&gt;Student.firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Fail"&lt;/span&gt;;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Struktury mogą zawierać funkcje, konstruktory, stałe, indeksatory, operatory, zdarzenia i typy zagnieżdżone oraz mogą implementować interfejsy. Użycie konstruktorów w strukturach różni się od konstruktorów w klasach. Cechy konstruktorów w strukturach:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konstruktory są opcjonalne lecz jeżeli występują to muszą posiadać parametry, konstruktor domyślny jest zabroniony.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Pola nie mogą być inicjalizowane w ciele struktury.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Pola mogą być inicjalizowane przez konstruktor lub po deklaracji struktury.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Konstruktor musi inicjalizować wszystkie pola struktury.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zmienne prywatne mogą być inicjalizowane tylko w konstruktorze.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Utworzenie nowej instancji struktury bez operatora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;new&lt;/strong&gt; nie wywoła konstruktora jeżeli jest obecny.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jeżeli struktura zawiera typ referencyjny (klasę) jako jedną ze swych zmiennych to trzeba bezpośrednio wywołać konstruktor typu referencyjnego.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład struktury z konstruktorem i funkcją:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create a Student struct that uses a constructor&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;struct&lt;/span&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; lastname;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; courseName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; first, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; last,&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; course)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.firstName = first;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.lastName = last;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.courseName = course;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;calcAverage&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; avg = ((score1 + score2 + score3 + score4 + score5) / &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.average = avg;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ struktury są przechowywane jako wartość na stosie to utworzenie ich kolekcji może powodować dużą konsumpcję pamięci.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład programu używającego struktury:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;struct&lt;/span&gt; Book&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; title;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; category;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; author;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; numPages;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; currentPage;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; ISBN;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; coverStyle;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Book&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; title, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; category, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; author, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; numPages, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;int&lt;/span&gt; currentPage, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; isbn, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; cover)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.title = title;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.category = category;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.author = author;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.numPages = numPages;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage = currentPage;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.ISBN = isbn;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.coverStyle = cover;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;nextPage&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage != &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.numPages)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage++;&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Current page is now: "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage);&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"At end of book."&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;prevPage&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage != &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage--;&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Current page is now: "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.currentPage);&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"At the beginning of the book."&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Book myBook = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Book(&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"MCSD Certification Toolkit (Exam 70-483)"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Certification"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Covaci, Tiberiu"&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;648&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;81118612095&lt;/span&gt;, &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Soft Cover"&lt;/span&gt;&lt;br /&gt;            );&lt;br /&gt;        Console.WriteLine(myBook.title);&lt;br /&gt;        Console.WriteLine(myBook.category);&lt;br /&gt;        Console.WriteLine(myBook.author);&lt;br /&gt;        Console.WriteLine(myBook.numPages);&lt;br /&gt;        Console.WriteLine(myBook.currentPage);&lt;br /&gt;        Console.WriteLine(myBook.ISBN);&lt;br /&gt;        Console.WriteLine(myBook.coverStyle);&lt;br /&gt;        myBook.nextPage();&lt;br /&gt;        myBook.prevPage();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Enumeratory&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; definiuje enumeratory jako odrębny typ który zawiera zbiór nazwanych zmiennych zwanych listą enumeratora. Nawet jeżeli nazwiesz pola listy enumeratora to kompilator nada im wartość całkowitą startując od zera i inkrementując o jeden każdego kolejnego członka listy, jest to zachowanie domyślne. Można nadpisać domyślne zachowanie poprzez przypisanie wartości do listy enumeratora. &lt;br /&gt;Przykład użycia enumeratora dla miesięcy w roku:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// enum call Months, using an overidden initializer&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;enum&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e; font-style: italic;"&gt;Months&lt;/span&gt;&lt;/span&gt;{Jan = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, Feb, Mar, Apr, May, Jun, Jul, Aug, Sept, Oct, Nov, Dec};&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Domyślnym typem stalych enumeratora jest &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;INT&lt;/strong&gt;. Można to zmienić poprzez użycie dwukropka po nazwie enumeratora i zadeklarowanie typu np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// using a non-default data type for an enum&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;enum&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e; font-style: italic;"&gt;Months&lt;/span&gt; : byte &lt;/span&gt;{Jan = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, Feb, Mar, Apr, May, Jun, Jul, Aug, Sept, Oct, Nov, Dec};&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Lista typów jest ograniczona do:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;byte&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;sbyte&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;short&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ushort&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;in&lt;/strong&gt;t&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;uint&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;long&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ulong&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Każda z wartości listy enumeratora może być deklarowana np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// enumeration to depict airspeeds for aircraft&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;enum&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;AirSpeeds&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    Vx&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;55&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    Vy&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;65&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    Vs0&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;50&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    Vs1&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;40&lt;/span&gt;,&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;    Vne&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;120&lt;/span&gt;&lt;br /&gt;{&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Enumeratory czynią kod czytelniejszym dla programisty i pozwalają na jego ponowne użycie. Enumeratory posiadają również metody które ułatwiają ich użycie. &lt;br /&gt;Przykład użycia enumeratora:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;enum&lt;/span&gt; Months&lt;br /&gt;    {&lt;br /&gt;        Jan = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;br /&gt;&lt;br /&gt;        Feb, &lt;br /&gt;&lt;br /&gt;        Mar, &lt;br /&gt;&lt;br /&gt;        Apr, &lt;br /&gt;&lt;br /&gt;        May, &lt;br /&gt;&lt;br /&gt;        Jun, &lt;br /&gt;&lt;br /&gt;        Jul, &lt;br /&gt;&lt;br /&gt;        Aug, &lt;br /&gt;&lt;br /&gt;        Sept, &lt;br /&gt;&lt;br /&gt;        Oct, &lt;br /&gt;&lt;br /&gt;        Nov, &lt;br /&gt;&lt;br /&gt;        Dec&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; name = Enum.GetName(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(Months), &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt;);&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The 8th month in the enum is "&lt;/span&gt; + name);&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The underlying values of the Months enum:"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; values &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; Enum.GetValues(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;typeof&lt;/span&gt;(Months)))&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine(values);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Typy referencyjne&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Programowanie zorientowane obiektowo pozwala na modelowanie obiektów świata rzeczywistego za pomocą klas. Klasy w języku C# są typami referencyjnymi. nazwa ta pochodzi od tego, że zmienne tego typu przechowują tylko referencje do aktualnego obiektu a ie jego wartość. &lt;br /&gt;W kodzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET&lt;/strong&gt; istnieją dwa logiczne rodzaje pamięci komputerowej które są używane. Są one zwane stosem (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;stack&lt;/strong&gt;) i stertą (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;heap&lt;/strong&gt;). Stos jest zakresem pamięci zarezerwowanej przez system operacyjny do wykonywania aplikacji. Jest to miejsce gdzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET&lt;/strong&gt; przechowuje typy proste. Jest to relatywnie mała ilość pamięci używana do wykonywania kodu. Przeważnie typy proste są tworzone i niszczone raczej szybko, istnieją tylko na czas w jakim aplikacja ich potrzebuje i dlatego stos jest w pewnym stopniu czysty w czasie wykonywania kodu. Jest to również powód tego, że otrzymujemy wyjątek braku pamięci (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;out-of-memory exception&lt;/em&gt;) jeżeli używamy nieskończonej pętli która przechowuje wartości na stosie. &lt;br /&gt;Sterta jest znacznie większym zakresem pamięci którego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET&lt;/strong&gt; używa do przechowywania utworzonych obiektów klas. Obiekt klasy potrafi potrzebować dużej ilości pamięci w zależności od rozmiaru klasy. Klasa posiada pola opisane typami prostymi, opisującymi cechy obiektu który klasa opisuje. Posiadają również metody które są funkcjonalnością którą klasa wystawia. &lt;br /&gt;Referencja jest adresem w pamięci. W ten sposób kiedy kod musi skopiować lub przypisać obiekt do innej zmiennej to kompilator kopiuje jedynie adres w pamięci a nie cały obiekt. &lt;br /&gt;Składnia tworzenia klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;MyClass&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// fields&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// properties&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// methods&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// events&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// delegates&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// nested classes&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Kolejność deklaracji poszczególnych komponentów klasy nie jest wymagana jak również nie wszystkie komponenty muszą być zadeklarowane. &lt;br /&gt;Pola klasy (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;fields&lt;/strong&gt;) są cechami charakterystycznymi obiektu który opisujemy np dla samochodu może to być kolor, marka itp.&lt;br /&gt;Właściwości (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;properties&lt;/strong&gt;) są powiązane bezpośrednio z polami. Służą do kontroli dostępu do pól klasy. &lt;br /&gt;Metody (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;methods&lt;/strong&gt;) są używane do udostępnienia funkcjonalności klasy np dla samochodu to włączenie silnika, przyspieszenie itp. &lt;br /&gt;Zdarzenia (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;events&lt;/strong&gt;) są również funkcjonalnością klasy ale używaną w inny sposób. Można o nich myśleć jako o rzeczach które wydarzą się na podstawie jakiegoś zewnętrznego wpływu np gdy jakiś sensor wykryje problem to wywołane zostanie zdarzenie i komputer w samochodzie nasłucha, że zostało wyzwolone zdarzenie. Jest to sposób informowanie obiektu przez inne obiekty, że coś się wydarzyło. Obiekt który zgłasza zdarzenie jest nazywany &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;event publisher&lt;/strong&gt; a obiekt który je odbiera&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;event subscriber&lt;/strong&gt;. &lt;br /&gt;Delegaty (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;delegates&lt;/strong&gt;) są definiowane przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Microsoft&lt;/em&gt; jako typy które odwołują się do metody. W języku C# delegata może być połączona z metodą która posiada podobną sygnaturę (typy argumentów). &lt;br /&gt;Klasy zagnieżdżone (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;nested classes&lt;/strong&gt;) są klasami które są zadeklarowane w ciele innej klasy.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Modyfikatory dostępu&lt;/h3&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Public&lt;/strong&gt; - Modyfikator dostępu, który deklaruje dostępność typu do którego jest przypisany. Jest to modyfikator z pełnym dostępem. Dostęp z poza ciała klasy lub struktury jest w nim dozwolony. Typy referencyjne i typy wartości oraz metody mogą być publiczne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Private&lt;/strong&gt; - Modyfikator dostępu, który deklaruje dostępność typu do którego jest przypisany. Jest to modyfikator z najmniejszym dostępem. Dostęp możliwy jest tylko w ciele klasy lub struktury. Typy referencyjne i typy wartości oraz metody mogą być prywatne.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Internal&lt;/strong&gt; - Modyfikator dostępu, który deklaruje dostępność typu do którego jest przypisany. Dostęp tylko w plikach należących do tego samego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET assembly&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Protected&lt;/strong&gt; - modyfikator dostępu członków obiektu. Dostęp możliwy jest tylko w tej samej klasie oraz klasach pochodnych.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Abstract&lt;/strong&gt; - modyfikator używany w klasach, mówi o tym, że ta klasa nie może posiadać instancji ale, że służy jako klasa bazowa dla innych klas w hierarchii dziedziczenia.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Async&lt;/strong&gt; - ustawia metodę lub wyrażenie lambda jako asynchroniczne. pozwala na uruchamianie długotrwałych procesów bez blokowania kodu wywołującego.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Const&lt;/strong&gt; - oznacza stałą, czyli pole które musi być zainicjowane w czasie deklaracji nie może być później zmieniane.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Event&lt;/strong&gt; - używany do deklaracji zdarzeń.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Extern&lt;/strong&gt; - używane by wskazać, że metoda została zadeklarowana i zaimplementowana na zewnątrz. Używane z zaimportowanymi plikami &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DLL&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;New&lt;/strong&gt; - Kiedy używane z członkami klasy ten modyfikator chowa odziedziczonych członków z klasy bazowej. Używamy kiedy chcemy użyć własnej wersji komponentu klasy a nie wersji odziedziczonej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Override&lt;/strong&gt; - Używany iedy chcemy zmienić funkcjonalność która została odziedziczona z klasy bazowej.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Partial&lt;/strong&gt; - klasy mogą być podzielone pomiędzy wieloma plikami w tym samym assembly. ten modyfikator mówi, że klasa jest podzielona pomiędzy plikami.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Readonly&lt;/strong&gt; - zmienne z tym modyfikatorem mogą być inicjowane jedynie podczas deklaracji lub w konstruktorze.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Sealed&lt;/strong&gt; - Używane w klasach, oznacza, że z klasy nie można dziedziczyć.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Static&lt;/strong&gt; - Kiedy jest używane z obiektami klasy oznacza, że obiekt należy do klasy a nie poszczególnych jej instancji. Istnieje wiele takich klas w &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET&lt;/strong&gt; które posiadają takie obiekty np klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Math&lt;/em&gt; lub &lt;em style="box-sizing: border-box; outline: none !important;"&gt;String&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Unsafe&lt;/strong&gt; - kod w C# jest kodem zarządzanym co oznacza, że operacje na pamięci są obsługiwane w chroniony sposób. Używając tego modyfikatora deklarujemy, że kontekst nie jest bezpieczny w odniesieniu do zarządzania pamięcią. Wskaźniki języka C++ są przykładem kodu który nie jest bezpieczny i musi być deklarowany z tym modyfikatorem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Virtual&lt;/strong&gt; - zezwala na przesłonięcie metod i właściwości w klasach dziedziczących.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Volatile&lt;/strong&gt; - Modyfikator pól który umożliwia modyfikowanie pola przez komponenty inne niż twój kod np przez system operacyjny.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Definiowanie pól&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pola mają dwa podstawowe typy, mogą być statyczne lub należeć do instancji klasy. Każda klasa może posiadać oba typy jednocześnie. Pola instancji to te które należą do każdej instancji klasy. Przykład deklaracji pól w klasie i utworzenia instancji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; StudentCount;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; lastName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; grade;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Student firstStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;        Student.StudentCount++;&lt;br /&gt;        Student secondStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;        Student.StudentCount++;&lt;br /&gt;        firstStudent.firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;;&lt;br /&gt;        firstStudent.lastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;;&lt;br /&gt;        firstStudent.grade = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"six"&lt;/span&gt;;&lt;br /&gt;        secondStudent.firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Tom"&lt;/span&gt;;&lt;br /&gt;        secondStudent.lastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Thumb"&lt;/span&gt;;&lt;br /&gt;        secondStudent.grade = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"two"&lt;/span&gt;;&lt;br /&gt;        Console.WriteLine(firstStudent.firstName);&lt;br /&gt;        Console.WriteLine(secondStudent.firstName);&lt;br /&gt;        Console.WriteLine(Student.StudentCount);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie konstruktorów&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konstruktor jest metodą która jest wywoływana kiedy tworzona jest instancja obiektu klasy. W konstruktorze można ustawić startowe wartości pól klasy. jeżeli nie zdefiniujemy żadnego konstruktora to kompilator C# utworzy konstruktor domyślny. konstruktor domyślny ustawia wartość każdego pola do jego wartości domyślnej. &lt;br /&gt;Składnia konstruktora:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// constructor syntax&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ClassName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;/* list of params */&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;//optional initializing statements;&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Konstruktor dla klasy student:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// constructor for the Student class&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; StudentCount;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; lastName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; grade;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; first, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; last, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; grade)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.firstName = first;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.lastName = last;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.grade = grade;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W powyższym kodzie utworzone zostały dwa konstruktory. Konstruktor używa modyfikatora &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;public&lt;/strong&gt; ponieważ musi być dostępny z poza klasy. Konstruktor ma zawsze taką samą nazwę jak klasa. pierwszy konstruktor w kodzie powyżej przyjmuje listę parametrów i inicjuje ich wartościami pola instancji klasy. Drugi konstruktor jest konstruktorem domyślnym który jest wygenerowany zawsze przez kompilator jeżeli nie zadeklarujemy innego. Kompilator decyduje który konstruktor użyć na podstawie listy parametrów wejściowych których użyjemy przy tworzeniu instancji klasy.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Metody&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody są komponentami w aplikacji które umożliwiają podział wymagań aplikacji na mniejsze kawałki. Dobrą praktyką jest tworzenie metod które odpowiadają tylko za jeden oddzielny kawałek funkcjonalności i metoda wykonuje tylko to co jet wymagane do osiągnięcia oczekiwanego rezultatu. Pozwala to na utrzymanie czystszego i bardziej czytelnego kodu a co za tym idzie łatwiejszego lokalizowania błędów. &lt;br /&gt;Metoda jest konstrukcją w kodzie która posiada nazwę, sygnaturę, blok wyrażeń i opcjonalne wyrażenie zwracające wynik&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;return&lt;/strong&gt;, które jest używane jeżeli metoda ma zadeklarowany zwracany typ wyniku. Jeżeli metoda jest typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;void&lt;/strong&gt; to użycie wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;return&lt;/strong&gt; spowoduje błąd kompilacji. &lt;br /&gt;Składnia metody:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt; syntax&lt;br /&gt;modifier &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;type&lt;/span&gt; name(optional arguments)&lt;br /&gt;{&lt;br /&gt;    statements;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład użycia metod w klasie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Student&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; StudentCount;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; lastName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; grade;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;ConcatenateName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; fullName = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.firstName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.lastName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; fullName;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DisplayName&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; name = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.ConcatenateName();&lt;br /&gt;        Console.WriteLine(name);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Student firstStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;        Student.StudentCount++;&lt;br /&gt;        Student secondStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student();&lt;br /&gt;        Student.StudentCount++;&lt;br /&gt;        firstStudent.firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"John"&lt;/span&gt;;&lt;br /&gt;        firstStudent.lastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Smith"&lt;/span&gt;;&lt;br /&gt;        firstStudent.grade = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"six"&lt;/span&gt;;&lt;br /&gt;        secondStudent.firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Tom"&lt;/span&gt;;&lt;br /&gt;        secondStudent.lastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Thumb"&lt;/span&gt;;&lt;br /&gt;        secondStudent.grade = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"two"&lt;/span&gt;;&lt;br /&gt;        firstStudent.DisplayName();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład metody przyjmującej parametry na wejściu:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// sample &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt; signature to accept values&lt;br /&gt;public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; sum(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; num1, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; num2)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; num1 + num2;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; sumValue = sum(&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metody przeciążone&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody są definiowane poprzez modyfikator, zwracany typ, nazwę i liczbę oraz typ parametrów wejściowych. Sygnaturą metody jest to co ją unikanie identyfikuje z pośród innych metod o tej samej nazwie. Sygnatura metody to jej nazwa oraz ilość i typy parametrów. metody przeciążone to metody o tej samej nazwie lecz o innej sygnaturze. &lt;br /&gt;Przykład metod przeciążonych obliczających pole powierzchni dla koła i prostokąta:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// calculate the area of a circle&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;calcArea&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; radius)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; area = Math.Pi * (r*r);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; area;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// calculate the area of a rectangle&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;calcArea&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; length, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; width)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; area = length * width;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; area;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Bardzo często używanymi metodami przeciążonymi są konstruktory klas. pozwalają one na selektywne inicjowanie członków klasy.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metody abstrakcyjne i przesłonięte&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody abstrakcyjne są metodami które nie opisują żadnego obiektu ale są utworzone z naciskiem na wewnętrzną formę i strukturę klasy. W programowaniu obiektowym są to metody dla których deklaruje się sygnaturę bez konkretnej implementacji. Zwane są one również metodami wirtualnymi (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;virtual method&lt;/strong&gt;). Klasy które dziedziczą z tej klasy muszą same zaimplementować ciała tych metod. klasa dziedzicząca musi w ten sposób przesłonić klasę abstrakcyjną poprzez implementację np.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// an abstract method inside a class&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;abstract&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;abstract&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;outputDetails&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metoda abstrakcyjna nie posiada implementacji w tym przykładzie i jest zakończona średnikiem. metody abstrakcyjne mogą być deklarowane tylko w klasach abstrakcyjnych. &lt;br /&gt;Przykład klasy abstrakcyjnej i klasy która ją przesłania:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// an abstract method inside a class&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;abstract&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;abstract&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;outputDetails&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;CollegeStudent&lt;/span&gt;: &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; lastName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; major;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; GPA;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;override&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;outputDetails&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Student "&lt;/span&gt; + firstName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + lastName + &lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" enrolled in "&lt;/span&gt; + major + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" is has a GPA of "&lt;/span&gt; + GPA);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Metody rozszerzające&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody rozszerzające umożliwiają rozszerzenie istniejących klas lub typów poprzez dodanie nowych metod bez modyfikacji oryginalnych klas lub typów oraz bez ich rekompilacji. On wersji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET 3.5&lt;/strong&gt; jest to jedyny sposób na dodanie funkcjonalności dla istniejących typów danych. &lt;br /&gt;Metody rozszerzające definiujemy publicznej statycznej klasie. Metoda rozszerzająca jest zawsze statyczna i przyjmuje jako parametr ze słowem kluczowym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;this&lt;/strong&gt; które wskazuje na instancję klasy w której się pojawia. Przykład rozszerzenia typu &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;INT&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;public &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt; class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;MyExtendedMethods&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    public &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; square(this &lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; num)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt; = num * num;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;result&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli rozszerzymy typ &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;object&lt;/strong&gt; to metoda rozszerzająca będzie dostępna dla każdego typu.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Parametry opcjonalne i nazwane&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zwykle kiedy wywołujemy metodę która ma wiele parametrów to musimy wstawić argumenty w kolejności w jakiej metoda ma zadeklarowane te parametry. Parametry nazwane pozwalają na dokładne przypisanie wartości parametrowi wg jego nazwy, niezależnie od kolejności deklaracji parametrów. Używamy parametrów nazwanych poprzez poprzedzenie wartości argumentu nazwą parametru który ma ona inicjować i znakiem dwukropka np.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; area = rectArea(length: &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;35.0&lt;/span&gt;, width: &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;25.5&lt;/span&gt;);&lt;br /&gt;        Console.WriteLine(area);&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;rectArea&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; length, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;double&lt;/span&gt; width)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; length * width;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Parametry opcjonalne pozwalają na użycie tylko niektórych argumentów przy użyciu metody. Parametry opcjonalne mają wyznaczoną w deklaracji wartość domyślną. Parametry domyślne można uzywać w metodach, konstruktorach, indekserach i delegatach. Wartości domyślne mogą być stałymi lub typami wartości oraz być tworzone jako nowy typ za pomocą słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;new&lt;/strong&gt;. Parametry opcjonalne są definiowane na końcu listy parametrów np.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// sample &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;with&lt;/span&gt; optional parameters&lt;br /&gt;public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; displayName(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt; first, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt; initial = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt; last = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;""&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Console&lt;/span&gt;.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;WriteLine&lt;/span&gt;(first + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + initial + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + last);&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Enkapsulacja&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Enkapsulacja jest jednym z założeń programowania obiektowego. Polega na pakowaniu obiektów składowych danej klasy tak, aby były one dostępne tylko metodom wewnętrznym danej klasy . Enkapsulacja jest również używana do “chowania” szczegółów implementacji klasy i ochrony charakterystyk obiektu który klasa opisuje.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Właściwości (properties)&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwości są publicznymi metodami których używamy aby udostępnić prywatne zmienne klasy. Poprzez nadanie zminnym klasy modyfikatora prywatnego sprawiamy, że nie są one dostępne z poza ciała klasy. Używając właściwości definiujemy publiczny dostęp do zmiennych klasy które chcemy udostępnić na zewnątrz. &lt;br /&gt;Właściwości również używają modyfikatorów dostępu. Można użyć dla nich modyfikatorów &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;public&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;private&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;protected&lt;/strong&gt;,&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;internal&lt;/strong&gt; lub &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;protected internal&lt;/strong&gt;. Właściwości mogą być również statyczne, wirtualne i abstrakcyjne. &lt;br /&gt;pomimo tego, że właściwości wyglądają jak charakterystyki klasy to nimi nie są. Właściwości są jedynie dwoma kluczowymi metodami dostępu i modyfikacji zmiennej klasy. pierwsza z nich jest znana jako metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;get&lt;/strong&gt; i jest używana do dostępu do zmiennej którą właściwość reprezentuje. Druga jest znana jako metoda &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;set&lt;/strong&gt; i służy do modyfikacji zmiennej którą właściwość reprezentuje. Składnia właściwości:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// sample propety syntax&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt; firstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; {&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; firstName;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt; { firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;;}&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tak jak w przykładzie w jeżyku C# rekomendowane jest aby prywatna zmienna deklarowana była z małej litery a właściwość posiadała taką samą nazwę rozpoczynającą się dużą literą lecz nie jest to obowiązek i nie powoduje żadnego błędu składni. &lt;br /&gt;Poprzez pominięcie którejś z metod właściwości możemy uczynić zmienną tylko do odczytu lub tylko do zapisu. &lt;br /&gt;Przykład klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Student&lt;/em&gt; która używa enkapsulacji:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt; middleInitial;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; lastName;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; age;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; program;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; gpa;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Student&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; first, &lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt; last)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.firstName = first;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.lastName = last;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; FirstName&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; firstName; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt; { firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; LastName&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; lastName; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt; { lastName = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt; MiddleInitial&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; middleInitial; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt; { middleInitial = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; Age&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; age; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt; &amp;gt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                age = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Student age must be greater than 6"&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;string&lt;/span&gt; Program&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; program; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt; { program = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;; }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;double&lt;/span&gt; GPA&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt; { &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt; gpa; }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt; &amp;lt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4.0&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                gpa = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"GPA cannot be greater than 4.0"&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;displayDetails&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.FirstName + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.MiddleInitial + &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;" "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.LastName);&lt;br /&gt;        Console.WriteLine(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Has a GPA of "&lt;/span&gt; + &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.GPA);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        Student myStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Tom"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Thumb"&lt;/span&gt;);&lt;br /&gt;        myStudent.MiddleInitial = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;'R'&lt;/span&gt;;&lt;br /&gt;        myStudent.Age = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;15&lt;/span&gt;;&lt;br /&gt;        myStudent.GPA = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3.5&lt;/span&gt;;&lt;br /&gt;        myStudent.displayDetails();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Właściwości indeksowane&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Właściwości indeksowane lub indeksery (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;indexers&lt;/strong&gt;), zachowują się nieco inaczej od standardowych właściwości. podstawowym celem indeksowanych właściwości jest zezwolenie na dostęp do grup elementów jak do tablic. Właściwość indeksowana jest identyfikowana za pomocą słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;this&lt;/strong&gt;. W klasie lub strukturze może istnieć tylko jedna właściwość indeksowana. &lt;br /&gt;Przykład klasy reprezentującej 32 bitowy adres IP:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;IPAddress&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;[] ip;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;[&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; index]&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;get&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.ip[index];&lt;br /&gt;        }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;set&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt; || &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt; == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;this&lt;/span&gt;.ip[index] = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;throw&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Exception(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Invalid value"&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;internal&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Main&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;        IPAddress myIP = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; IPAddress();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// initialize the IP address to all zeros&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;32&lt;/span&gt;; i++)&lt;br /&gt;        {&lt;br /&gt;            myIP[i] = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Typy generyczne&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;typy generyczne zostały dodane w wersji 2.0 języka C#. Atutem użycia typów generycznych jest to, że możesz projektować klasę i jej metody bez wyszczególniania typów jej elementów aż do czasu deklaracji i tworzenia instancji klasy. Zaletami typów generycznych są: ponowne użycie kodu, bezpieczeństwo typów i wydajność.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Definiowanie typów generycznych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Typy generyczne definiujemy za pomocą nawiasów ostrych (), gdzie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T&lt;/strong&gt; jest typem generycznym. Przykład definicji klasy generycznej kolejki:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// example of a generic style Queue&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;class&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;GenericQueue&lt;/span&gt;&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;T&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;Enqueue&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;(T obj)&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;public&lt;/span&gt; T &lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;DeQueue&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;typ generyczny posiada wszystkie cechy innych typów referencyjnych.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Używanie typów generycznych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Tworząc obiekt klasy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;GenericQueue&lt;/em&gt; należy wstawić typ obiektu zamiast znaku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T&lt;/strong&gt;. Przykład tworzenia instancji klasy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// generic queue that will be used to store Student objects&lt;/span&gt;&lt;br /&gt;GenericQueue&amp;lt;Student&amp;gt; StudentQueue = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; GenericQueue&amp;lt;Student&amp;gt;();&lt;br /&gt;Student myStudent = &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;new&lt;/span&gt; Student(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Tom"&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Thumb"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// store the myStudent object in the StudentQueue&lt;/span&gt;&lt;br /&gt;StudentQueue.Enqueue(myStudent);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// retrieve the myStudent object from the StudentQueue&lt;/span&gt;&lt;br /&gt;StudentQueue.Dequeue();&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ponieważ typ referencyjny jest wyspecyfikowany w trakcie tworzenia instancji obiektu to nie trzeba rzutować typów.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Definiowanie metod generycznych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody generyczne są definiowane z parametrem typu w ostrym nawiasie tak jak klasy generyczne. Przykład metody generycznej używanej w algorytmach sortujących:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// example &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;of&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;generic&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;method&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;with&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;type&lt;/span&gt; parameters&lt;br /&gt;public &lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Swap&lt;/span&gt;&amp;lt;T&amp;gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; T valueOne, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; T valueTwo)&lt;br /&gt;{&lt;br /&gt;    T temp = valueOne;&lt;br /&gt;    valueOne = valueTwo;&lt;br /&gt;    valueTwo = temp;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Metody generyczne używają słowa kluczowego &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ref&lt;/strong&gt; przed użyciem typu generycznego w liście parametrów. Oznacza to, że argument będzie wstawiony poprzez referencję.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie metod generycznych&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Używając metod generycznych musimy wstawić poprawny typ w wywołaniu metody, zastępując parametr &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;T&lt;/strong&gt;. Przykład sortowania używającego zdefiniowanej metody generycznej &lt;em style="box-sizing: border-box; outline: none !important;"&gt;Swap&lt;/em&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;internal class &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    private &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Main&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important;"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt;[] arrInts = new[] { &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;5&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;6&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;7&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;9&lt;/span&gt;, &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;8&lt;/span&gt; };&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;char&lt;/span&gt;[] arrChar = new[] { 'f', 'a', 'r', 'c', 'h' };&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Sorting&lt;/span&gt;: integer &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Sort&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; arrInts.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Length&lt;/span&gt;; i++)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; j = i + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; j &amp;lt; arrInts.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Length&lt;/span&gt;; j++)&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (arrInts[i] &amp;gt; arrInts[j])&lt;br /&gt;                {&lt;br /&gt;                    swap&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt;&amp;gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; arrInts[i], &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; arrInts[j]);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Sorting&lt;/span&gt;: character &lt;span style="box-sizing: border-box; outline: none !important;"&gt;Sort&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; i = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; i &amp;lt; arrChar.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Length&lt;/span&gt;; i++)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important;"&gt;int&lt;/span&gt; j = i + &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;; j &amp;lt; arrChar.&lt;span style="box-sizing: border-box; outline: none !important;"&gt;Length&lt;/span&gt;; j++)&lt;br /&gt;            {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (arrChar[i] &amp;gt; arrChar[j])&lt;br /&gt;                {&lt;br /&gt;                    swap&amp;lt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;char&lt;/span&gt;&amp;gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; arrChar[i], &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; arrChar[j]);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;void&lt;/span&gt; swap&amp;lt;T&amp;gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; T valueOne, &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;ref&lt;/span&gt; T valueTwo)&lt;br /&gt;    {&lt;br /&gt;        T temp = valueOne;&lt;br /&gt;        valueOne = valueTwo;&lt;br /&gt;        valueTwo = temp;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie ograniczeń w typach generycznych&lt;/h3&gt;
Typy generyczne mogą być ograniczane poprzez użycie klauzuli &lt;strong&gt;where&lt;/strong&gt;. Poniższa lista zawiera listę różnych typów ograniczeń:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;where T:struct&lt;/strong&gt; - typ musi być typem wartości (tylko &lt;em&gt;Nullable&lt;/em&gt; są niedozwolone).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;where T : class&lt;/strong&gt; - typ musi być typem referencyjnym (klasą, interfejsem, delegatą lub tablicą).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;where T : new()&lt;/strong&gt; - typ musi posiadać publiczny konstruktor domyślny.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;where T : &amp;lt;base class name&amp;gt; &lt;/strong&gt;- typ musi dziedziczyć z klasy bazowej lub być jej typu.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;where T : &amp;lt;interface name&amp;gt; &lt;/strong&gt;- typ musi implementować interfejs, możliwe jest użycie wielu interfejsów.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;where T:U&lt;/strong&gt; - typ &lt;em&gt;T&lt;/em&gt; musi być typem &lt;em&gt;U&lt;/em&gt; lub z niego dziedziczyć.&lt;/li&gt;
&lt;/ul&gt;
Przykład użycia klauzuli &lt;strong&gt;where&lt;/strong&gt; w definicji klasy:
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;class MyClass&amp;lt;T&amp;gt; where T : class, new()
{
 public MyClass()
 {
 MyProperty = &lt;span class="hljs-keyword"&gt;default&lt;/span&gt;&lt;span class="hljs-container"&gt;(&lt;span class="hljs-type"&gt;T&lt;/span&gt;)&lt;/span&gt;;
 }
 T MyProperty { get; set; }
}&lt;/pre&gt;
Słowo kluczowe &lt;strong&gt;default(T) &lt;/strong&gt;inicjuje zmienną domyślną wartością typu.
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Typy wartości&lt;/strong&gt; są najprostszymi typami używanymi prostych lub złożonych danych jak struktury i enumeratory.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Struktura&lt;/strong&gt; jest konstrukcją podobną do lekkiej klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Enumeracja&lt;/strong&gt; czyni kod czytelniejszym poprzez nadanie nazw stałym wartościom.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Enkapsulacja&lt;/strong&gt; pozwala na chowanie szczegółów implementacyjnych klasy.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;Klasy i metody generyczne&lt;/strong&gt; pozwalają na deklarację klas i metod bez wyszczególnionego typu.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
      <pubDate>Mon, 21 Sep 2015 23:41:22 Z</pubDate>
      <a10:updated>2015-09-21T23:41:22Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1119</guid>
      <link>http://smsoft.pl/blog/i-podstawowa-struktura-programu/</link>
      <title>I. Podstawowa struktura programu</title>
      <description>&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Ta notatka ma na uwadze zrozumienie pewnych podstawowych struktur programowania które można użyć do formowania logiki w kodzie. Kiedy piszemy program to algorytmy które opisujemy kodem są formowane poprzez logiczny przepływ programu bazujący na decyzjach i powtórzeniach. Dokonujemy tego poprzez użycie iteracji na kolekcjach, wykonywanie pętli jak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;for&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;while&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;do-while&lt;/strong&gt;, używanie wyrażenia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;switch&lt;/strong&gt;, użycie konstrukcji warunkowej &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;if/then&lt;/strong&gt;, użycie operatorów i wyliczanie wyrażeń.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Pierwszy program&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;kod w języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; jest pisany za pomocą serii wyrażen. Specyfikacja języka dzieli te wyrażenia na dwa podstawowe typy: wyrażenia proste i złożone.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wyrażenia proste&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W języku &lt;em style="box-sizing: border-box; outline: none !important;"&gt;C#&lt;/em&gt; proste wyrażenia to te które kończą się znakiem średnika (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;;&lt;/strong&gt;) i są używane do obsługi akcji programu jak niżej wymienione:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;deklaracja zmiennych (declaration statements).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;przypisanie wartości do zmiennej (assignment statements).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;wywołanie metody w kodzie.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;wyrażenie rozgałęziające które zmienia przepływ programu &lt;br /&gt;Przykłady prostych wyrażeń:&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// variable declaration &lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; counter;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;float&lt;/span&gt; distance;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;string&lt;/span&gt; firstName;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// assignment &lt;/span&gt;&lt;br /&gt;counter = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;distance = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;4.5&lt;/span&gt;;&lt;br /&gt;firstName = &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Bill"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// jump statements&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;return&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// empty statement&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #66d9ef;"&gt;void&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #a6e22e;"&gt;SomeFunction&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f8f8f2;"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (DoSomething())&lt;br /&gt;    {&lt;br /&gt;        ;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Wyrażenia złożone&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wyrażenia złożone to takie które mogą ująć lub ujmują jedno lub wiele wyrażeń prostych tworząc blok kodu otoczony poprzez nawiasy klamrowe: &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;{}&lt;/strong&gt;. typowymi wyrażeniami złożonymi są pętle i struktury decyzyjne jak &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;foreach()&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;if()&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;switch&lt;/strong&gt;, &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;do()&lt;/strong&gt; itp.&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładem wyrażenia złożonego może być iteracja tablicy wartości i wykonanie akcji używając różnych wyrażeń np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;//&lt;span style="box-sizing: border-box; outline: none !important;"&gt; check &lt;/span&gt;to see how many values in an&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;are even numbers&lt;br /&gt;int&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;] numbers = { 5, 24, 36, 19, 45, 60, 78 };&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;int &lt;/span&gt;evenNums = 0;&lt;br /&gt;foreach&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; (&lt;/span&gt;var num in numbers&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt; Console.Writeline(&lt;/span&gt;num&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important;"&gt; if &lt;/span&gt;(num % 2 == 0&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        evenNums++;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Kontrola przepływu programu&lt;/h2&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wszystkie aplikacje potrzebują pewnych opcji przepływu programu. W programowaniu strukturalnym przepływ programu odbywał się z góry na dół. niestety ta metoda nie rozwiązuje pewnych problemów ze świata realnego. Czasem w aplikacji potrzebujemy podjąć pewne inne akcje w zależności od od wyniku innych akcji. Nazywa się to rozgałęzianiem kodu. Przepływ programu przechodzi do innej lokacji w kodzie i wraca kiedy wykona wszystkie instrukcje które są w nim zawarte lub powtarza pewne linie kodu aż do zakończenia wszystkich zadań.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Instrukcje warunkowe&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Instrukcje warunkowe w C# są to te które wyliczają warunek i w jego wyniku wykonują pewną akcję, nie podejmują żadnej akcji lub wybierają pomiędzy dostępnymi akcjami do wykonania. Do wyliczania warunków C# wykorzystuje:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;operatory relacji&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;wyrażenia logiczne&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;operatory logiczne&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;operatory warunkowe (operator trójargumentowy) &lt;br /&gt;Warunki w C# pozwalają na porównanie wartości przechowywanych w zmiennych, stałych i literałach. Zmienna (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;variable&lt;/em&gt;&lt;/strong&gt;) jest nazwaną lokacją w pamięci która pozwala na zapis wartości w celu późniejszego wykorzystania. Stała (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&lt;em style="box-sizing: border-box; outline: none !important;"&gt;constant&lt;/em&gt;&lt;/strong&gt;) to również miejsce w pamięci ale nie można zmienić jej wartości po zadeklarowaniu.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operatory relacyjne:&lt;/p&gt;
&lt;table border="0" style="box-sizing: border-box; outline: none !important; max-width: 100%; border-collapse: collapse; border-spacing: 0px; margin-bottom: 20px; background-color: transparent;"&gt;
&lt;thead&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;th align="left" style="box-sizing: border-box; outline: none !important; text-align: left; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Operator&lt;/th&gt;
&lt;th align="right" style="box-sizing: border-box; outline: none !important; text-align: right; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Znaczenie&lt;/th&gt;
&lt;th align="center" style="box-sizing: border-box; outline: none !important; text-align: center; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Przykład&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;lt;&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;mniejsze niż&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 &amp;lt; expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;większe niż&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 &amp;gt; expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;lt;=&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;mniejsze niż lub równe&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 &amp;lt;= expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;gt;=&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;większe niż lub równe&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 &amp;gt;= expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;==&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;równość&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 == expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;!=&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;nie równe&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 != expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operatory logiczne:&lt;/p&gt;
&lt;table border="0" style="box-sizing: border-box; outline: none !important; max-width: 100%; border-collapse: collapse; border-spacing: 0px; margin-bottom: 20px; background-color: transparent;"&gt;
&lt;thead&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;th align="left" style="box-sizing: border-box; outline: none !important; text-align: left; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Operator&lt;/th&gt;
&lt;th align="right" style="box-sizing: border-box; outline: none !important; text-align: right; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Znaczenie&lt;/th&gt;
&lt;th align="center" style="box-sizing: border-box; outline: none !important; text-align: center; padding: 0.5em; vertical-align: bottom; border: 1px solid #dddddd; font-weight: bold;"&gt;Przykład&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Wariant jednoargumentowy zwraca adres swojego argumentu&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&amp;amp; expr1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Wariant dwuargumentowy jest operatorem logicznym &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AND&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 &amp;amp; expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;I&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Dwuargumentowy operator logiczny &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OR&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 I expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;^&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Bitowe &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;XOR&lt;/strong&gt;. Zwraca &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; gdy tylko jeden operand jest równy &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt;&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 ^ expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;!&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Jednoargumentowy operator negacji&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;!expr1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;~&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Bitowy operator uzupełnienia&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;~expr&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&amp;amp;&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Warunkowy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AND&lt;/strong&gt; wykonujący operację logiczną &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;AND&lt;/strong&gt; na argumentach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;bool&lt;/em&gt;. Drugi argument jest wyliczany tylko w razie potrzeby (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;short-circuit evaluation&lt;/em&gt;).&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 &amp;amp;&amp;amp; expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;II&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Warunkowy &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OR&lt;/strong&gt; wykonujący operację logiczną &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;OR&lt;/strong&gt; na argumentach &lt;em style="box-sizing: border-box; outline: none !important;"&gt;bool&lt;/em&gt;. Wylicza tylko drugi argument jeżeli wystarcza (&lt;em style="box-sizing: border-box; outline: none !important;"&gt;short-circuit evaluation&lt;/em&gt;).&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;expr1 II expr2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Wskazuje prawdę w wyrażeniu&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;bool success = true;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; outline: none !important;"&gt;
&lt;td align="left" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;false&lt;/strong&gt;&lt;/td&gt;
&lt;td align="right" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;Wskazuje fałsz w wyrażeniu&lt;/td&gt;
&lt;td align="center" style="box-sizing: border-box; outline: none !important; padding: 0.5em; vertical-align: top; border: 1px solid #dddddd;"&gt;bool success = false;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Najczęściej wykorzystywanymi operatorami są (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&amp;amp;&lt;/strong&gt;) i (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;||&lt;/strong&gt;) oraz wartości logiczne &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;true&lt;/strong&gt; i &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;false&lt;/strong&gt;. Operatory są optymalizowane w czasie wyliczania wyrażeń, optymalizacja ta jest nazywana &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;short-circuit evaluation&lt;/strong&gt;. oznacza to, że dla operacji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;&amp;amp;&amp;amp;&lt;/strong&gt; nie sprawdza się drugiego warunku jeżeli pierwszy jest fałszywy. to uproszczenie daje pewien zysk w wydajności poprzez wyeliminowanie pewnego nakładu pracy jaki komputer musi wykonać. Aby lepiej to zrozumieć należy znać algorytm porównywania wykonywany przez &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt; w czasie porównania:&lt;/p&gt;
&lt;ol style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Pobranie instrukcji i załadowanie do pamięci.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Inkrementacja wskaźnika instrukcji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Odszukanie w pamięci pierwszej wartości, pobranie JEJ z pamięci i umieszczenie w rejestrze.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Dostęp do pamięci w celu pobrania drugiej wartości i umieszczenie jej w rejestrze &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonanie porównania i umieszczenie wyniku w rejestrze &lt;em style="box-sizing: border-box; outline: none !important;"&gt;CPU&lt;/em&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonanie &lt;em style="box-sizing: border-box; outline: none !important;"&gt;pop&lt;/em&gt; na stosie dla wskaźnika instrukcji aby powrócić do kodu który był wykonywany przed porównaniem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zwrócenie wartości porównania do kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonanie następnej instrukcji kodu.&lt;/li&gt;
&lt;/ol&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Operator trójargumentowy:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;condition ? &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;true&lt;/span&gt; : &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;value&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;false&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Podejmowanie decyzji w kodzie&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Język C# umożliwia programiście wykorzystanie struktur decyzyjnych służących do podejmowania decyzji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;IF&lt;/h4&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// single if statement syntax&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;condition&lt;/span&gt;)&lt;br /&gt;    statement;&lt;br /&gt;remaining code statements;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;W nawiasach okrągłych instrukcja &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IF&lt;/strong&gt; zawiera warunek logiczny który jest wyliczany i jeżeli jego wartość jest prawdą to zostaje wykonane wyrażenie następujące po nawiasie. Jeżeli wartość warunku jest fałszywa to wyrażenie po nawiasie jest pomijane. Używając tej instrukcji zaleca się aby wyrażenie wykonywane jeżeli wynikiem jest &lt;em style="box-sizing: border-box; outline: none !important;"&gt;true&lt;/em&gt; zamykać w nawiasy klamrowe, nawet jeżeli jest to wyrażenie proste.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// single if statement syntax with a statement block&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;condition&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    statement;&lt;br /&gt;}&lt;br /&gt;remaining code statements;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;instrukcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IF&lt;/strong&gt; mogą być zagnieżdżone.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// nested if statement&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;(condition1)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt;(condition2)&lt;br /&gt;    {&lt;br /&gt;        statement;&lt;br /&gt;    }&lt;br /&gt;    outer statement;&lt;br /&gt;}&lt;br /&gt;remaining code statements;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykładowy program testujący działanie instrukcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IF&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;using System;&lt;br /&gt;internal &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;class&lt;/span&gt; Program&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;private&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;static&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;void&lt;/span&gt; Main(string[] args)&lt;br /&gt;    {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// declare some variables for use in the code and assign initial values&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; first = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; second = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// use a single if statement to evaluate a condition and output&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// some text&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// indicating the results&lt;/span&gt;&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Single if statement"&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (first == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The if statement evaluated to true"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This line outputs regardless of the if condition"&lt;/span&gt;);&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create an if statement that evaluates two conditions and executes&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// statements only if both are true&lt;/span&gt;&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"An if statement using &amp;amp;&amp;amp; operator."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (first == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt; &amp;amp;&amp;amp; second == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"The if statement evaluated to true"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This line outputs regardless of the if condition"&lt;/span&gt;);&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// create nested if statements&lt;/span&gt;&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Nested if statements."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (first == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;if&lt;/span&gt; (second == &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Both outer and inner conditions are true."&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt;            Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Outer condition is true, inner may be true."&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"This line outputs regardless of the if condition"&lt;/span&gt;);&lt;br /&gt;        Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Wynik działania kodu:&lt;/p&gt;
&lt;blockquote style="box-sizing: border-box; outline: none !important; padding: 15px 20px; margin: 0px 0px 1.1em; border-left-width: 10px; border-left-style: solid; border-left-color: rgba(102, 128, 153, 0.0745098); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: rgba(102, 128, 153, 0.0470588);"&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em; font-size: 1em; font-weight: 300;"&gt;Single if statement &lt;br /&gt;The if statement evaluated to true &lt;br /&gt;This line outputs regardless of the if condition&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em; font-size: 1em; font-weight: 300;"&gt;An if statement using &amp;amp;&amp;amp; operator. &lt;br /&gt;The if statement evaluated to true &lt;br /&gt;This line outputs regardless of the if condition&lt;/p&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px; font-size: 1em; font-weight: 300;"&gt;Nested if statements. &lt;br /&gt;Both outer and inner conditions are true. &lt;br /&gt;Outer condition is true, inner may be true. &lt;br /&gt;This line outputs regardless of the if condition&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli chcemy aby w przypadku kiedy wartość wyrażenia warunkowego jest fałszywa wykonywany był inny blok kodu to używamy instrukcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IF-ELSE&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;//&lt;span style="box-sizing: border-box; outline: none !important;"&gt; if-else &lt;/span&gt;statement syntax&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;if &lt;/span&gt;(condition&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    statement1;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;    statement2;&lt;br /&gt;}&lt;br /&gt;remaining code statements;&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Dla wielu warunków i rozgałęzień kodu można używać instrukcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IF, ELSE IF&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;//&lt;span style="box-sizing: border-box; outline: none !important;"&gt; if-else &lt;/span&gt;if statement syntax&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;if &lt;/span&gt;(condition1&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    statement1;&lt;br /&gt;}&lt;br /&gt;else&lt;span style="box-sizing: border-box; outline: none !important;"&gt; if &lt;/span&gt;(condition2&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    statement2;&lt;br /&gt;}&lt;br /&gt;else&lt;span style="box-sizing: border-box; outline: none !important;"&gt; if &lt;/span&gt;(condition3&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    statement3;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;    statement4;&lt;br /&gt;}&lt;br /&gt;remaining code statements;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;SWITCH&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Jeżeli chcemy ten sam warunek poddać testowaniu z różnymi wartościami to możemy użyć instrukcji &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;SWITCH&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// switch statement syntax&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;switch&lt;/span&gt; (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;condition&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;:&lt;br /&gt;        statement1;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;:&lt;br /&gt;        statement2;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;3&lt;/span&gt;:&lt;br /&gt;        statement3;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;default&lt;/span&gt;:&lt;br /&gt;        defaultStatement;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Można również wykonać tą sama instrukcję dla wielu warunków:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;switch&lt;/span&gt; (number)&lt;br /&gt;{&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; 1:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; 2:&lt;br /&gt;        Console.Writeline (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Contained in the set of whole numbers."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; -&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;1&lt;/span&gt;:&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;case&lt;/span&gt; -10:&lt;br /&gt;        Console.WriteLine (&lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;"Contained in the set of Integers."&lt;/span&gt;);&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;break&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h3 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.7em; text-align: start;"&gt;Użycie pętli&lt;/h3&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Użycie pętli w kodzie pozwala na powtórzenie przez aplikację serii instrukcji. Język C# dostarcza cztery struktury pętli:&lt;/p&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;for&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;foreach&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;while&lt;/strong&gt;&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;do-while&lt;/strong&gt; &lt;br /&gt;Decyzja której z nich użyć zależy od wymagań ale wszystkie z nich dostarczają funkcjonalność powtarzalnego wykonywania instrukcji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;FOR&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pętla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FOR&lt;/strong&gt; pozwala na powtarzalne wykonywanie serii instrukcji do czasu aż nie zostanie spełniony wyznaczony warunek. Pętla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FOR&lt;/strong&gt; składa się z trzech elementów: inicjatora, warunku i iteratora (ang. &lt;em style="box-sizing: border-box; outline: none !important;"&gt;initializer&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;condition&lt;/em&gt;, &lt;em style="box-sizing: border-box; outline: none !important;"&gt;iterator&lt;/em&gt;) oddzielonych znakiem średnika (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;;&lt;/strong&gt;). &lt;br /&gt;// for statement syntax&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt;(initializer; condition; &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;iterator&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    statement(s);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Inicjator służy do deklaracji i inicjalizacji zmiennych startowych które będą używane w pętli. Warunek określa kiedy pętla ma zostać zatrzymana, natomiast iterator służy do modyfikacji zmiennych w każdym przebiegu pętli. Np:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// Count up to 10 in increments of 2&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; counter = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;; counter &amp;lt;= &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;; counter += &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;2&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(counter);&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Zmienne zadeklarowane w pętli nie są widoczne poza pętlą (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;scope&lt;/strong&gt;). &lt;br /&gt;Przykład nieskończonej się pętli:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;//&lt;/span&gt; infinite &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;loop&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; C&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;for&lt;/span&gt;(;;)&lt;br /&gt;{&lt;br /&gt;    statement;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;FOREACH&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pętla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FOREACH&lt;/strong&gt; używana jest do iteracji po wszystkich elementach z kolekcji. Kolekcjami zazwyczaj są tablice ale mogą nimi być także inne obiekty &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;.NET&lt;/strong&gt; implementujące interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// foreach syntax&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;foreach&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;type&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;in&lt;/span&gt; collection)&lt;br /&gt;{&lt;br /&gt;    statement;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;“&lt;em style="box-sizing: border-box; outline: none !important;"&gt;Type&lt;/em&gt;” jest typem obiektów kolekcji. Przykład wykorzystania pętli:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;// foreach loop to average grades in an&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array&lt;br /&gt;&lt;/span&gt;// set up an integer&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;and assign some values&lt;br /&gt;int&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;] arrGrades =&lt;span style="box-sizing: border-box; outline: none !important;"&gt; new &lt;/span&gt;int&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;[&lt;/span&gt;] {78, 89, 90, 76, 98, 65};&lt;br /&gt;// create three variables to hold the sum, number of grades,&lt;span style="box-sizing: border-box; outline: none !important;"&gt; and &lt;/span&gt;the average&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;int &lt;/span&gt;total = 0;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;int &lt;/span&gt;gradeCount = 0;&lt;span style="box-sizing: border-box; outline: none !important;"&gt;&lt;br /&gt;double &lt;/span&gt;average = 0.0;&lt;br /&gt;// loop to iterate over each integer value in the&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array&lt;br /&gt;&lt;/span&gt;// foreach doesn't need to know the size initially as it is determined&lt;br /&gt;// at the time the&lt;span style="box-sizing: border-box; outline: none !important;"&gt; array &lt;/span&gt;is accessed.&lt;br /&gt;foreach(int grade in arrGrades&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    total = total + grade; //&lt;span style="box-sizing: border-box; outline: none !important;"&gt; add &lt;/span&gt;each grade value to total&lt;br /&gt;    gradeCount++; // increment counter for use in average&lt;br /&gt;}&lt;br /&gt;average = total / gradeCount; // calculate average of grades&lt;br /&gt;Console.WriteLine(average&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;)&lt;/span&gt;;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;WHILE&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Podobnie do pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FOR&lt;/strong&gt; pętla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WHILE&lt;/strong&gt; jest wykonywana aż do czasu kiedy warunek który jest zapisany w nawiasie pętli jest spełniony, kiedy warunek zwróci fałsz pętla jest przerywana i przechodzi do dalszego wykonywania instrukcji.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// while statement syntax&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt;(&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;condition&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    statement;&lt;br /&gt;}&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// while statement example&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; someValue = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt;(someValue &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(someValue);&lt;br /&gt;    someValue++;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;DO-WHILE&lt;/h4&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Pętla &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DO-WHILE&lt;/strong&gt; działa podobnie do pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WHILE&lt;/strong&gt; z dwoma wyjątkami. Po pierwsze blok instrukcji w tej pętli jest zawsze wykonywany co najmniej jeden raz niezależnie od warunku. Po drugie warunek jest sprawdzany po wykonaniu bloku instrukcji a nie na początku.&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;//&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;do&lt;/span&gt;-&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;loop&lt;/span&gt; syntax&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;do&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    statement;&lt;br /&gt;} &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (condition);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Przykład:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// do-while statement example&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;int&lt;/span&gt; someValue = &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;do&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(someValue);&lt;br /&gt;    someValue++;&lt;br /&gt;} &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (someValue &amp;lt; &lt;span style="box-sizing: border-box; outline: none !important; color: #ae81ff;"&gt;10&lt;/span&gt;);&lt;/pre&gt;
&lt;p style="box-sizing: border-box; outline: none !important; margin: 0px 0px 1.1em;"&gt;Użyteczny przykład użycia &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DO-WHILE&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;pre style="box-sizing: border-box; outline: none !important; font-family: &amp;amp;apos; source code pro&amp;amp;apos;, monospace; font-size: 0.9em; white-space: pre-wrap; display: block; padding: 2px; margin: 0px 0px 1.1em; word-break: break-word; word-wrap: break-word; color: #333333; border: 0px; border-radius: 5px; text-align: start; background: #f6f6f6;"&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #75715e;"&gt;// while statement example&lt;/span&gt;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt; someValue;&lt;br /&gt;&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;do&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    someValue = (&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;char&lt;/span&gt;) Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;Read&lt;/span&gt;();&lt;br /&gt;    Console.&lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;WriteLine&lt;/span&gt;(someValue);&lt;br /&gt;} &lt;span style="box-sizing: border-box; outline: none !important; color: #f92672;"&gt;while&lt;/span&gt; (someValue != &lt;span style="box-sizing: border-box; outline: none !important; color: #e6db74;"&gt;'q'&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h2 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 2.15em; text-align: start;"&gt;Podsumowanie&lt;/h2&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wyrażenia proste&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Są zakończone znakiem średnika (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;;&lt;/strong&gt;).&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zwykle są zapisane w jednej linii.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zwykle używane dla deklaracji i przypisania wartości zmiennej.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;Wyrażenia złożone&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Zwykle zawierają wyrażenia proste w nawiasach klamrowych &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;{}&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Mogą być zakończone znakiem średnika (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;;&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;IF-THEN-ELSE&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Używane do podejmowania decyzji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wykonuje ścieżkę kodu która spełnia podany warunek.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Nie wymaga nawiasów klamrowych ale ich używanie jest dobrą praktyką.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ELSE IF&lt;/strong&gt; służy do wybrania alternatywnej ścieżki wykonania kodu.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Klauzula &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;ELSE&lt;/strong&gt; służy do wybrania alternatywnej ścieżki dla fałszywego wyniku warunku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Może być zagnieżdżona.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;SWITCH&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Może testować różne typy danych w warunku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Jest czystszym kodem niż zagnieżdżone instrukcje &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IF&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Może zawierać klauzulę &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;DEFAULT&lt;/strong&gt; dla przypadku gdy żadna wartość nie spełnia warunku.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Wyrażenie &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;BREAK&lt;/strong&gt; oznacza koniec bloku instrukcji dla spełnionego warunku.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;FOR&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Prosta pętla.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Używa inicjatora, warunku i iteratora oddzielonych średnikami i otoczonych okrągłym nawiasem.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Może być zagnieżdżona.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Warunek jest sprawdzany na początku każdej iteracji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;FOREACH&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Służy do iterowania po elementach kolekcji implementującej interfejs &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;IEnumerable&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Może być zagnieżdżona.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;WHILE&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Inicjator i iterator nie są częścią pętli jak w przypadku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FOR&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Warunek jest sprawdzany na początku każdej iteracji.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="box-sizing: border-box; outline: none !important; color: #2c3f51; font-family: &amp;amp;apos; helvetica neue&amp;amp;apos;, arial, &amp;amp;apos;hiragino sans gb&amp;amp;apos;, stheiti, &amp;amp;apos;microsoft yahei&amp;amp;apos;, &amp;amp;apos;wenquanyi micro hei&amp;amp;apos;, simsun, song, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"&gt;
&lt;h4 style="box-sizing: border-box; outline: none !important; font-family: inherit; font-weight: bold; color: inherit; margin: 1.2em 0px 0.6em; font-size: 1.25em; text-align: start;"&gt;DO-WHILE&lt;/h4&gt;
&lt;ul style="box-sizing: border-box; outline: none !important; margin-top: 0px; margin-bottom: 1.1em;"&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Podobna do pętli &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;WHILE&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Inicjator i iterator nie są częścią pętli jak w przypadku &lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;FOR&lt;/strong&gt;.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Warunek jest sprawdzany na końcu iteracji.&lt;/li&gt;
&lt;li style="box-sizing: border-box; outline: none !important;"&gt;Kończy się średnikiem (&lt;strong style="box-sizing: border-box; outline: none !important; font-weight: bold;"&gt;;&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
      <pubDate>Sat, 12 Sep 2015 15:48:37 Z</pubDate>
      <a10:updated>2015-09-12T15:48:37Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1115</guid>
      <link>http://smsoft.pl/blog/routing/</link>
      <title>Routing</title>
      <description>&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Wymaga modułu &lt;b&gt;angular-route.js&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Konfiguracja zasad w &lt;b&gt;$routeProvider &lt;/b&gt;np:&lt;b&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;i&gt;          $routeProvider.when("/main",{&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;               templateUrl:"main.html", &lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;               controller: "MainController"&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          })&lt;/i&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Trzeba skonfigurować szablon widoków&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;Konfiguracja routingu&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;trzeba dodać skrypt &lt;b&gt;angular-route.js&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;$routeParams&lt;/b&gt; - serwis zbierający parametry routingu&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html   - SZABLON:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app="githubViewer"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script data-require="angular-route@*" data-semver="1.2.14" src="http://code.angularjs.org/1.2.14/angular-route.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="MainController.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="UserController.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="RepoController.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="github.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Github Viewer&amp;lt;/h1&amp;gt;
&amp;lt;div &lt;b&gt;ng-view&lt;/b&gt;&amp;gt;

&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js  -KONFIGURACJA APLIKACJI:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;(function(){

var app = angular.module("githubViewer", ["&lt;b&gt;ngRoute&lt;/b&gt;"]);

app.config(function(&lt;b&gt;$routeProvider&lt;/b&gt;){
&lt;b&gt;$routeProvider
.when("/main", {
templateUrl: "main.html",
controller: "MainController"
})
.when("/user/:username", {
templateUrl: "user.html",
controller: "UserController"
})
.when("/repo/:username/:reponame", {
templateUrl: "repo.html",
controller: "RepoController"
})
.otherwise({redirectTo:"/main"});&lt;/b&gt;
});

}());&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;MainController.js :&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;(function() {

var app = angular.module("githubViewer");

var MainController = function($scope, $interval, $location) {

var decrementCountdown = function() {
$scope.countdown -= 1
if ($scope.countdown &amp;lt; 1) {
$scope.search($scope.username);
}
};

var countDownInterval = null;
var startCountDown = function() {
countDownInterval = $interval(decrementCountdown, 1000, $scope.countdown);
};


$scope.search = function(username) {
if (countDownInterval) {
$interval.cancel(countDownInterval);
$scope.countdown = null;
}
//route to user page
&lt;b&gt;$location.path("/user/"+username);&lt;/b&gt;
};

$scope.username = "angular";
$scope.repoSortOrder = "-stargazers_count";
$scope.countdown = 5;
startCountDown();

};

app.controller("MainController", MainController);

}());&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;&lt;b&gt;main.html:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt; &amp;lt;div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  {{countdown}}&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;form name="searchUser" ng-submit="search(username)"&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;input type="search" required placeholder="Username to find" ng-model="username" /&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;input type="submit" value="Search"&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/form&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;UserController.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;(function() {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var app = angular.module("githubViewer");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var UserController = function($scope, github, $routeParams) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var onUserComplete = function(data) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      $scope.user = data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      github.getRepos($scope.user)&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        .then(onRepos, onError);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var onRepos = function(data) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      $scope.repos = data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var onError = function(reason) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      $scope.error = "Could not fetch the data.";&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    $scope.username = $routeParams.username;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    $scope.repoSortOrder = "-stargazers_count";&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    github.getUser($scope.username)&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      .then(onUserComplete, onError);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  app.controller("UserController", UserController);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;}());&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;user.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;h2&amp;gt;{{user.name}}&amp;lt;/h2&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  {{error}}&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;img ng-src="http://www.gravatar.com/avatar/{{user.gravatar_id}}" title="{{user.name}}"&amp;gt;Order:&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;select ng-model="repoSortOrder"&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;option value="+name"&amp;gt;Name&amp;lt;/option&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;option value="-stargazers_count"&amp;gt;Stars&amp;lt;/option&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;option value="+language"&amp;gt;Language&amp;lt;/option&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/select&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;table&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;thead&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;tr&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;/tr&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/thead&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;tbody&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;tr ng-repeat="repo in repos | orderBy:repoSortOrder"&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;td&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        &amp;lt;a href="#/repo/{{user.login}}/{{repo.name}}"&amp;gt;{{repo.name}}&amp;lt;/a&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;/td&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;/tr&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/tbody&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/table&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;a href="#/main"&amp;gt;Back to search&amp;lt;/a&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;RepoController:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;(function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var module = angular.module("githubViewer");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var RepoController = function($scope, $routeParams, github){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var onRepo = function(data){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      $scope.repo = data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var onError = function(reason){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      $scope.error = reason;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var reponame = $routeParams.reponame;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var username = $routeParams.username;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    github.getRepoDetails(username, reponame)&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      .then(onRepo, onError);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  module.controller("RepoController", RepoController);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;}());&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;repo.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;h2&amp;gt;{{repo.name}}&amp;lt;/h2&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  Issues: {{repo.open_issues_count}}&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;ul&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;li ng-repeat="user in repo.collaborators"&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;img src="http://www.gravatar.com/avatar/{{user.gravatar_id}}" alt="{{user.login}}"&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      {{user.login}}&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;/li&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/ul&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;a href="#/main"&amp;gt;Back to search&amp;lt;/a&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;a href="#/user/{{repo.owner.login}}"&amp;gt;Back to {{repo.owner.login}}&amp;lt;/a&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;github.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;(function() {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var github = function($http) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var getUser = function(username) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      return $http.get("https://api.github.com/users/" + username)&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        .then(function(response) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;          return response.data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        });&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var getRepos = function(user) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      return $http.get(user.repos_url)&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        .then(function(response) {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;          return response.data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        });&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    var getRepoDetails = function(username, reponame){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      var repo;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      var repoUrl = "https://api.github.com/repos/" + username + "/" + reponame;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      return $http.get(repoUrl)&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        .then(function(response){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;          repo = response.data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;          return $http.get(repoUrl + "/collaborators");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        })&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        .then(function(response){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;          repo.collaborators = response.data;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;          return repo;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;        });&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    return {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      getUser: getUser,&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      getRepos: getRepos,&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;      getRepoDetails: getRepoDetails&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var module = angular.module("githubViewer");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  module.factory("github", github);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;}());&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 03 Sep 2015 20:26:04 Z</pubDate>
      <a10:updated>2015-09-03T20:26:04Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1117</guid>
      <link>http://smsoft.pl/blog/serwisy/</link>
      <title>Serwisy</title>
      <description>&lt;div&gt;&lt;b&gt;setTimeout&lt;/b&gt; - metoda JS wykonująca metodę przekazaną jako pierwszy argument po upływie ilości milisekund podanych jako drugi parametr np &lt;i&gt;&lt;b&gt;setTimeout(doWork, 2000);&lt;/b&gt;&lt;/i&gt;
&lt;div&gt;&lt;b&gt;setInterval&lt;/b&gt; - metoda JS wykonująca metodę przekazaną jako pierwszy argument co ilości milisekund podanych jako drugi parametr np&lt;i&gt;&lt;b&gt; setInterval(doWork, 2000);&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;b&gt;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Serwisy Angular wykonujące to samo:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;$timeout&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;$interval&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;Łatwiej jest testować aplikację za pomocą testów jednostkowych z użyciem serwisów Angular.&lt;/div&gt;
&lt;div&gt;Wszystkie serwisy trzeba zarejestrować jako parametry kontrolera np &lt;i&gt;var MainController = function($scope, &lt;b&gt;$http&lt;/b&gt;, &lt;b&gt;$interval&lt;/b&gt;){...}&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app="githubViewer"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"&amp;gt;
&amp;lt;/script&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body ng-controller="MainController"&amp;gt;
&amp;lt;h1&amp;gt;{{message}}&amp;lt;/h1&amp;gt;

&amp;lt;div&amp;gt;{{ error }}&amp;lt;/div&amp;gt;

{{countdown}}
&amp;lt;form name="searchUser" ng-submit="search(username)"&amp;gt;
&amp;lt;input type="search" required placeholder="Username to find" ng-model="username" /&amp;gt;
&amp;lt;input type="submit" value="Search"&amp;gt;
&amp;lt;/form&amp;gt;

&amp;lt;div ng-include="'userdetails.html'" ng-show="user"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;script.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;(function() {

var app = angular.module("githubViewer", []);

var MainController = function($scope, $http, &lt;b&gt;$interval&lt;/b&gt;) {

var onUserComplete = function(response) {
$scope.user = response.data;
$http.get($scope.user.repos_url)
.then(onRepos, onError);
};

var onRepos = function(response){

$scope.repos = response.data;

};

var onError = function(reason) {
$scope.error = "Could not fetch the data.";
};

&lt;b&gt;var decrementCountdown = function(){
$scope.countdown -=1
if($scope.countdown &amp;lt; 1){
$scope.search($scope.username);
}
};&lt;/b&gt;

&lt;b&gt;var startCountDown = function(){
$interval(decrementCountdown, 1000, $scope.countdown);
};&lt;/b&gt;


$scope.search = function(username){
$http.get("https://api.github.com/users/" + username)
.then(onUserComplete, onError);
};

$scope.username = "angular";
$scope.message = "GitHub Viewer";
$scope.repoSortOrder = "-stargazers_count";
&lt;b&gt;$scope.countdown = 5;
startCountDown();&lt;/b&gt;

};

app.controller("MainController", ["$scope", "$http", "$interval", MainController]);

}());&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Inne przykładowe serwisy Angular:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;$log&lt;/li&gt;
&lt;li&gt;$animate&lt;/li&gt;
&lt;li&gt;$anchorScroll - skroluje do adresu w HTML po id&lt;/li&gt;
&lt;li&gt;$location - adres w przeglądarce&lt;/li&gt;
&lt;li&gt;$browser&lt;/li&gt;
&lt;li&gt;$window&lt;/li&gt;
&lt;li&gt;$timeout&lt;/li&gt;
&lt;li&gt;$interval&lt;/li&gt;
&lt;li&gt;$http&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Własne serwisy:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;kod wielokrotnego użytku&lt;/li&gt;
&lt;li&gt;współdzielone dane&lt;/li&gt;
&lt;li&gt;uproszczenie kodu&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;b&gt;Przykład: githubService&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;github.js:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt; (function() {&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;
&lt;/i&gt;
&lt;blockquote&gt;&lt;i&gt;  var github = function($http) {
var getUser = function(username) {
return $http.get("https://api.github.com/users/" + username)
.then(function(response) {
return response.data;
});
};
var getRepos = function(user) {
return $http.get(user.repos_url)
.then(function(response) {
return response.data;
});
};
return {
getUser: getUser,
getRepos: getRepos
};
};
var module = angular.module("githubViewer");
module.factory("github", github);
}());&lt;/i&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;i&gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;script.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;(function() {

var app = angular.module("githubViewer", []);

var MainController = function($scope, &lt;b&gt;github&lt;/b&gt;, $interval, $log, $anchorScroll, $location) {

var onUserComplete = function(data) {
$scope.user = data;
&lt;b&gt;github.getRepos($scope.user)
.then(onRepos, onError);&lt;/b&gt;
};

var onRepos = function(data) {
$scope.repos = data;
$location.hash("userDetails");
$anchorScroll();
};

var onError = function(reason) {
$scope.error = "Could not fetch the data.";
};

var decrementCountdown = function() {
$scope.countdown -= 1
if ($scope.countdown &amp;lt; 1) {
$scope.search($scope.username);
}
};

var countDownInterval = null;
var startCountDown = function() {
countDownInterval = $interval(decrementCountdown, 1000, $scope.countdown);
};


$scope.search = function(username) {
$log.info("Searching for " + username);
&lt;b&gt;github.getUser(username)
.then(onUserComplete, onError);&lt;/b&gt;



$http.get("https://api.github.com/users/" + username)
.then(onUserComplete, onError);
if (countDownInterval) {
$interval.cancel(countDownInterval);
$scope.countdown = null;
}
};

$scope.username = "angular";
$scope.message = "GitHub Viewer";
$scope.repoSortOrder = "-stargazers_count";
$scope.countdown = 5;
startCountDown();

};

app.controller("MainController", MainController);

}());&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 03 Sep 2015 20:25:38 Z</pubDate>
      <a10:updated>2015-09-03T20:25:38Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1116</guid>
      <link>http://smsoft.pl/blog/dyrektywy-i-widoki-w-angularjs/</link>
      <title>Dyrektywy i widoki w AngularJS</title>
      <description>&lt;div&gt;&lt;b&gt;Dyrektywy&lt;/b&gt;
&lt;div&gt;&lt;b&gt;{{}}&lt;/b&gt;
&lt;div&gt;Data binding - bindują dane modelu do widoku np &lt;i&gt;{{message}}&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;ng-model&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Wstawianie danych z widoku (formularz) do modelu np:&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;b&gt;{{username}}&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;  &amp;lt;form name="searchUser"&amp;gt;
&amp;lt;input type="search" placeholder="User name to find" &lt;b&gt;ng-model="username"&lt;/b&gt;/&amp;gt;
&amp;lt;input type="submit" value="Search"/&amp;gt;
&amp;lt;/form&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;ng-click&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Zdarzenie obsługujące kliknięcie np &lt;i&gt;&amp;lt;input type="submit" value="Search" &lt;b&gt;ng-click="search(username)&lt;/b&gt;"/&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;Parametr username nie jest potrzebny ponieważ istnieje już w modelu.&lt;/div&gt;
&lt;div&gt;&lt;b&gt;ng-submit&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Zdarzenie obsługujące zatwierdzenie formularza np &lt;i&gt;&amp;lt;form name="searchUser" &lt;b&gt;ng-submit="search(username)"&lt;/b&gt;&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app="githubViewer"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body ng-controller="MainController"&amp;gt;
&amp;lt;h1&amp;gt;{{message}}&amp;lt;/h1&amp;gt;
&amp;lt;div&amp;gt;{{error}}&amp;lt;/div&amp;gt;
&amp;lt;form name="searchUser" &lt;b&gt;ng-submit&lt;/b&gt;="search(username)"&amp;gt;
&amp;lt;input type="search" required placeholder="User name to find" &lt;b&gt;ng-model&lt;/b&gt;="username" /&amp;gt;
&amp;lt;input type="submit" value="Search"/&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;h2&amp;gt;{{user.name}}&amp;lt;/h2&amp;gt;
&amp;lt;img ng-src="http://www.gravatar.com/avatar/{{user.gravatar_id}}" title="{{user.name}} "&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;(function() {

var app = angular.module("githubViewer", []);
var MainController = function($scope, $http) {
var onUserComplete = function(response) {
$scope.user = response.data;
};
var onError = function(reason) {
$scope.error = "Could not fetch the user."
}
$scope.search = function(username) {
$http.get("https://api.github.com/users/" + username)
.then(onUserComplete, onError);
};
$scope.username = "angular";
$scope.message = "GitHub Viewer";
};
app.controller("MainController", MainController);
}());&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;ng-repeat&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Służy do iterowania po kolekcjach (jak pętla foreach) np:&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;table&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;    &amp;lt;thead&amp;gt;
&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt;
&amp;lt;/thead&amp;gt;
&amp;lt;tbody&amp;gt;
&amp;lt;tr &lt;b&gt;ng-repeat="repo in repos"&lt;/b&gt;&amp;gt;
&amp;lt;td&amp;gt;&lt;b&gt;{{repo.name}}&lt;/b&gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&lt;b&gt;{{repo.stargazers_count | number}}&lt;/b&gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&lt;b&gt;{{repo.language}}&lt;/b&gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;
&amp;lt;/table&amp;gt;&lt;/i&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;ng-show / ng-hide&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Dyrektywy służące do pokazywania/chowania elementu. Po znaku równości dajemy wyrażenie bool które musi być spełnione.&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;div &lt;b&gt;ng-show&lt;/b&gt;="user"&amp;gt;...&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;table &lt;b&gt;ng-hide&lt;/b&gt;="!user"&amp;gt;...&amp;lt;/table&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;ng-include&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Pozwala na załączenie istniejącego już pliku do widoku, ponowne użycie kodu.&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;div &lt;b&gt;ng-include="'strona.html'"&lt;/b&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;Filtry&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;Pozwalają na stosowanie pewnych zachowań w wyrażeniach.&lt;/div&gt;
&lt;div&gt;Podstawowy format: &lt;i&gt;&lt;b&gt;expression|filterName:parameter&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;number&lt;/b&gt; - jest to filtr który formatuje liczbę &lt;i&gt;&lt;b&gt;{{repo.stargazers_count | number}}&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;currency&lt;/b&gt; - filtr dodający walutę &lt;b&gt;&lt;i&gt;{{ammount|currency:"USD$"}}&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;date&lt;/b&gt; - formatuje datę &lt;i&gt;&lt;b&gt;{{startDate | date:'short'}}&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;filter&lt;/b&gt; - filtruje kolekcje &lt;b&gt;&lt;i&gt;repo in repos|filter:searchTerm&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;json&lt;/b&gt; - &lt;b&gt;{{repo|json}}&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;limitTo&lt;/b&gt; - ogranicza liczbę wystąpień &lt;b&gt;&lt;i&gt;repo in repos|limitTo:10&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;lowercase&lt;/b&gt; - małe litery &lt;i&gt;&lt;b&gt;{{user.name|uppercase}}&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;uppercase&lt;/b&gt; - duże litery &lt;i&gt;&lt;b&gt;{{user.name|uppercase}}&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;orderBy&lt;/b&gt; -sortuje &lt;i&gt;repo in repos|orderBy:'name'&lt;/i&gt; aby sortować malejąco należy użyć - przed &lt;i&gt;name&lt;/i&gt;, analogicznie + dla rosnąco&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app="githubViewer"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body ng-controller="MainController"&amp;gt;
&amp;lt;h1&amp;gt;{{message}}&amp;lt;/h1&amp;gt;

&amp;lt;div&amp;gt;{{error}}&amp;lt;/div&amp;gt;

&amp;lt;form name="searchUser" ng-submit="search(username)"&amp;gt;
&amp;lt;input type="search" required placeholder="User name to find" ng-model="username" /&amp;gt;
&amp;lt;input type="submit" value="Search"/&amp;gt;
&amp;lt;/form&amp;gt;

&amp;lt;div &lt;/i&gt;&lt;i&gt;ng-show="user"&lt;/i&gt;&lt;i&gt;&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;i&gt;    &amp;lt;h2&amp;gt;{{user.name}}&amp;lt;/h2&amp;gt;
&amp;lt;img ng-src="http://www.gravatar.com/avatar/{{user.gravatar_id}}" title="{{user.name}} "&amp;gt;
Order:
&amp;lt;select ng-model="repoSortOrder"&amp;gt;
&amp;lt;option value="+name"&amp;gt;Name&amp;lt;/option&amp;gt;
&amp;lt;option value="-stargazers_count"&amp;gt;Stars&amp;lt;/option&amp;gt;
&amp;lt;option value="+language"&amp;gt;Language&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;
&amp;lt;table &lt;/i&gt;&lt;i&gt;ng-hide="!user"&lt;/i&gt;&lt;i&gt;&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;i&gt;    &amp;lt;thead&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Stars&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Language&amp;lt;/th&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/thead&amp;gt;
&amp;lt;tbody&amp;gt;
&amp;lt;tr ng-repeat="repo in repos | orderBy:repoSortOrder"&amp;gt;
&amp;lt;td&amp;gt;{{repo.name}}&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;{{repo.stargazers_count | number}}&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;{{repo.language}}&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;
&amp;lt;/table&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;i&gt;(function() {

var app = angular.module("githubViewer", []);

var MainController = function($scope, $http) {

var onUserComplete = function(response) {
$scope.user = response.data;
$http.get($scope.user.repos_url)
.then(onRepos, onError);

};
var onRepos = function(response){
$scope.repos = response.data;
};
var onError = function(reason) {
$scope.error = "Could not fetch the data."
}

$scope.search = function(username) {
$http.get("https://api.github.com/users/" + username)
.then(onUserComplete, onError);
};

$scope.username = "angular";
$scope.message = "GitHub Viewer";
$scope.repoSortOrder = '-stargazers_count';
};

app.controller("MainController", MainController);&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;}());&lt;/i&gt;&lt;/div&gt;</description>
      <pubDate>Thu, 03 Sep 2015 20:25:07 Z</pubDate>
      <a10:updated>2015-09-03T20:25:07Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1118</guid>
      <link>http://smsoft.pl/blog/kontrolery-angularjs/</link>
      <title>Kontrolery AngularJS</title>
      <description>&lt;div&gt;&lt;b&gt;NG-CONTROLLER&lt;/b&gt; - dyrektywa deklarująca kontroler np:
&lt;div&gt;&lt;i&gt;     &amp;lt;div ng-app&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          &amp;lt;div &lt;b&gt;ng-controller = "MainController"&lt;/b&gt;&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          ...&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          &amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     &amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;Kontroler jest funkcją JS którą AngularJS wywołuje np:&lt;/div&gt;
&lt;div&gt;&lt;i&gt;var &lt;b&gt;MainController&lt;/b&gt; = function($scope){&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          $scope.message = "Hello!";&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     };&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;Kontrolery maja zawsze parametr &lt;b&gt;$scope&lt;/b&gt;. Właściwości &lt;b&gt;$scope&lt;/b&gt; to nasz model np &lt;b&gt;$scope.message&lt;/b&gt;.&lt;/div&gt;
&lt;div&gt;Znak &lt;b&gt;$&lt;/b&gt; oznacza, że używamy komponentu AngularJS.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;html ng-app&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;head&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/head&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;body ng-controller="MainController"&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;p&amp;gt;{{message}}&amp;lt;/p&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/body&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var MainController = function($scope){&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  $scope.message = "Hello Angular!";&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;};&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Właściwości kontrolerów:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;1. Wstawia model do $scope, nigdy nie manipuluje bezpośrednio na HTML tylko binduje model do widoku.&lt;/div&gt;
&lt;div&gt;&lt;img src="file:///C:/Users/MA4ED~1.SIM/AppData/Local/Temp/enhtmlclip/Image.png" alt="" /&gt;&lt;/div&gt;
&lt;div&gt;2. W $cope można przekazywać obiekty np:&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;div ng-controller="QuoteController"&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          &amp;lt;div&amp;gt;Stock: {{stock.symbol}}&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          &amp;lt;div&amp;gt;Price: {{stock.price}}&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     &amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;3. Kontrolery mogą być zagnieżdżone np:&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     &amp;lt;div ng-controller="QuoteController"&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          &amp;lt;div&amp;gt;Stock: {{stock.symbol}}&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;          &amp;lt;div&amp;gt;Price: {{stock.price}}&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&amp;lt;div ng-controller="ChartController"&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;               &amp;lt;img src="{{chart.source}}" alt="{{chart.description}}"/&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;i&gt;&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     &amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;html ng-app&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;head&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/head&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;body ng-controller="MainController"&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;h1&amp;gt;{{message}}&amp;lt;/h1&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;div&amp;gt;First name: {{person.firstName}}&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;div&amp;gt;Last name: {{person.lastName}}&amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;      &amp;lt;img ng-src="{{person.imageSrc}}" title="{{person.firstName}} {{person.lastName}}"&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    &amp;lt;/div&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  &amp;lt;/body&amp;gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var MainController = function($scope){&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  var person = {&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    firstName:"Scott",&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    lastName:"Allen",&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;    imageSrc:"http://odetocode.com/Images/scott_allen_2.jpg"&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  $scope.message = "Hello Angular!";&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;  $scope.person = person;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;};&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Serwis $http&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Enkapsuluje komunikację HTTP (GET, POST, PUT, DELETE)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;$http&lt;/b&gt; może być drugim parametrem funkcji kontrolera -&amp;gt; &lt;i&gt;var PersonController = function($scope, &lt;b&gt;$http&lt;/b&gt;){...}&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Używa metod http do komunikacji np &lt;i&gt;$scope.user = $http.get("/user/1783");&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Zawsze zwraca obiekt &lt;b&gt;PROMISE&lt;/b&gt; ponieważ nie wiadomo kiedy żądanie się zakończy.&lt;/li&gt;
&lt;li&gt;Funkcja then wykonywana dla żądania posiada dwie funkcje wewnętrzne dla obsługi poprawnego żądania i błędnego.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var promise = $http.get("/user/1783");&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;promise.then(function(response){&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     $scope.user = response.data;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;},&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;function(reason){&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;     $scope.error = "Error";&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;});&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;GitHub API - przykładowe źródło danych&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;dostępne dla JS&lt;/li&gt;
&lt;li&gt;zwraca JSON&lt;/li&gt;
&lt;li&gt;bez uwierzytelnienia&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;np: &lt;a href="https://api.github.com/users/odetocode"&gt;https://api.github.com/users/odetocode&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body ng-controller="MainController"&amp;gt;
&amp;lt;h1&amp;gt;{{message}}&amp;lt;/h1&amp;gt;
&amp;lt;div&amp;gt;{{error}}&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;First name: {{user.name}}&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;Location: {{user.location}}&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;img ng-src="{{user.avatar_url}}" title="{{user.name}}"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&lt;/i&gt;&amp;gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;var MainController = function($scope, $http){

var onUserComplete = function(response){
$scope.user = response.data;
};
var onError = function(reason){
$scope.error = "Could not fetch the user."
}
$http.get("https://api.github.com/users/odetocode")
.then(onUserComplete);

$scope.message = "Hello Angular!";
};&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Moduły&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Kontrolery nie powinny być zmiennymi globalnymi.&lt;/li&gt;
&lt;li&gt;Kontrolery powinny być osadzone w modułach.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;b&gt;Praca z modułami:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Utworzenie modułu i nadanie mu nazwy np &lt;i&gt;&lt;b&gt;var app = angular.module("githubViewer", []);&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;W nawiasie kwadratowym dodajemy listę zależności dla tworzonego modułu.&lt;/li&gt;
&lt;li&gt;Zarejestrowanie kontrolera w module np &lt;i&gt;&lt;b&gt;app.controller("MainController", MainController);&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;W html trzeba powiedzieć Angularowi, że używamy modułu w &lt;b&gt;ng-app&lt;/b&gt; np &lt;i&gt;&lt;b&gt;&amp;lt;html ng-app="githubViewer"&amp;gt;&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;Aby narzędzia minimalizujące kod JS nie zmieniły ważnych nazw zmiennych przy rejestracji kontrolera używa się zapisu: &lt;i&gt;&lt;b&gt;app.controller("MainController", ["$scope","$http",MainController]); &lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;b&gt;Przykład:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;indeks.html:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app="githubViewer"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body ng-controller="MainController"&amp;gt;
&amp;lt;h1&amp;gt;{{message}}&amp;lt;/h1&amp;gt;
&amp;lt;div&amp;gt;{{error}}&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;First name: {{user.name}}&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;Location: {{user.location}}&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;img ng-src="{{user.avatar_url}}" title="{{user.name}}"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;b&gt;app.js:&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;&lt;i&gt;(function() {

var app = angular.module("githubViewer", []);

var MainController = function($scope, $http) {

var onUserComplete = function(response) {
$scope.user = response.data;
};
var onError = function(reason) {
$scope.error = "Could not fetch the user."
}
$http.get("https://api.github.com/users/odetocode")
.then(onUserComplete);

$scope.message = "Hello Angular!";
};

app.controller("MainController", ["$scope","$http",MainController]);
}());&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Thu, 03 Sep 2015 20:24:35 Z</pubDate>
      <a10:updated>2015-09-03T20:24:35Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1114</guid>
      <link>http://smsoft.pl/blog/start-z-angularjs/</link>
      <title>Start z AngularJS</title>
      <description>&lt;div&gt;&lt;b&gt;Strony:&lt;/b&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://angularjs.org/"&gt;https://angularjs.org/&lt;/a&gt; - strona projektu&lt;/li&gt;
&lt;li&gt;&lt;a href="https://builtwith.angularjs.org/"&gt;https://builtwith.angularjs.org/&lt;/a&gt; - strona projektów zbudowanych w Angular&lt;/li&gt;
&lt;li&gt;&lt;a href="http://plnkr.co/"&gt;http://plnkr.co/&lt;/a&gt; - edytor napisany w Angular&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;b&gt;Wymagania:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Dodanie tagu &lt;b&gt;&amp;lt;script src="angular.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Dodanie atrybutu &lt;b&gt;ng-app&lt;/b&gt; do &lt;b&gt;HTML&lt;/b&gt; - jest to dyrektywa Angular, w skrócie angular-application.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;b&gt;NG-APP&lt;/b&gt; można dodać do dowolnego elementu strony np &amp;lt;html ng-app&amp;gt; lub &amp;lt;body ng-app&amp;gt;.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;Hello world:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html ng-app="plunker"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;meta charset="utf-8" /&amp;gt;
&amp;lt;title&amp;gt;AngularJS Plunker&amp;lt;/title&amp;gt;
&amp;lt;script&amp;gt;document.write('&amp;lt;base href="' + document.location + '" /&amp;gt;');&amp;lt;/script&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css" /&amp;gt;
&amp;lt;script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.25/angular.js" data-semver="1.2.25"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body ng-controller="MainCtrl"&amp;gt;
&amp;lt;p&amp;gt;Hello {{name}}!&amp;lt;/p&amp;gt;
&lt;b&gt;{{ 843/42 }}&lt;/b&gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Linijka {{ 843/42 }} da w rezultacie wynik dzielenia ponieważ jest wynikiem &lt;b&gt;binding expression&lt;/b&gt;.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;b&gt;JavaScript patterns:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Funkcje jako abstrakcja&lt;/b&gt; - funkcje pozwalają w js na osiągnięcie poziomu abstrakcji&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var work = function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  console.log("working hard!");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;};&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var doWork = function(f){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  console.log("start");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  try{&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  f();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  }&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  catch(ex){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    console.log(ex);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  }&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  console.log("end");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;};&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;doWork(work);&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Funkcje jako moduły&lt;/b&gt; - funkcja może działać jak klasa, zawierać metody i zmienne&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var createWorker = function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var task1 = function () {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    console.log("task1");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var task2 = function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    console.log("task2");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  return {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    job1: task1,&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    job2: task2&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;};&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var worker = createWorker();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;worker.job1();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;worker.job2();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Funkcje aby unikać zmiennych globalnych&lt;/b&gt; - aby uniknąć zmiennych globalnych należy zamieszczać je w funkcjach (np caly program jako f-cja globalna) które mają zawsze swój scope.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;(function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var createWorker = function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var task1 = function () {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    console.log("task1");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  var task2 = function(){&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    console.log("task2");&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  return {&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    job1: task1,&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;    job2: task2&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;  };&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;};&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;var worker = createWorker();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;worker.job1();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;worker.job2();&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;i&gt;}());&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;Powyższa struktura nazywa się w JS jako &lt;b&gt;IIFE&lt;/b&gt; (immediately invoked function expression) lub "&lt;b&gt;iffy&lt;/b&gt;".&lt;/div&gt;</description>
      <pubDate>Thu, 03 Sep 2015 20:23:52 Z</pubDate>
      <a10:updated>2015-09-03T20:23:52Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1113</guid>
      <link>http://smsoft.pl/blog/lekcja-46-uzycie-wskazowek-planu-wykonania/</link>
      <title>Lekcja 46. Użycie wskazówek planu wykonania</title>
      <description>&lt;p&gt;W niektórych przypadkach optymalizator zapytań nie potrafi znaleźć najlepszego planu wykonania. W niektórych przypadkach można wyznaczyć lepszy plan wykonania za pomocą wskazówek optymalizacji (ang. &lt;em&gt;optimizer hints&lt;/em&gt;). Aby skorzystać z podpowiedzi trzeba zmodyfikować zapytanie. Dodatkowo istnieje jeszcze inna opcja pozwalająca na zmianę planu wykonania - dosłownie przewodnik planu (ang. &lt;em&gt;plan guide&lt;/em&gt;). Przewodników planu wykonania można użyć kiedy nie możemy lub z jakichś powodów nie chcemy zmienić tekstu zapytania. &lt;em&gt;SQL Serwer&lt;/em&gt; używa przewodników planu aby dołączyć wskazówki lub ustalony plan wykonania do zapytań.&lt;/p&gt;
&lt;h2&gt;Wskazówki optymalizacyjne&lt;/h2&gt;
&lt;p&gt;Wskazówki optymalizacyjne (ang. &lt;em&gt;optimizer hints&lt;/em&gt;) są dyrektywami dotyczącymi wykonania zapytań. Można użyć ich z instrukcją &lt;em&gt;SELECT&lt;/em&gt; i innymi instrukcjami służącymi do modyfikacji danych. Istnieją trzy główne rodzaje wskazówek: wskazówki tabel (ang. &lt;em&gt;table hints&lt;/em&gt;), wskazówki zapytań (ang. &lt;em&gt;query hints&lt;/em&gt;) i wskazówki złączeń (ang. &lt;em&gt;join hints&lt;/em&gt;). Kiedy używamy wskazówek to zmieniamy treść zapytań. &lt;em&gt;SQL Serwer&lt;/em&gt; musi wykonać zapytanie lub jego część zawsze w ten sam sposób. Zapytanie może być częścią aplikacji więc może być trudne do zmiany. Rozkład dystrybucji danych może ulec zmianie po pewnym czasie i wskazówka która poprawiała wydajność w przeszłości może powodować po pewnym czasie jej spadek. Powinno używać się wszelkich innych sposobów jak tworzenie odpowiednich indeksów i statystyk oraz używanie przewodników planu wykonania przed użyciem wskazówek. Używaj wskazówek w ostateczności i sprawdzaj ich użyteczność co jakiś czas. Wskazówki definiujemy w sekcji &lt;em&gt;OPTION&lt;/em&gt; klauzul &lt;em&gt;SELECT&lt;/em&gt;, &lt;em&gt;INSERT&lt;/em&gt;, &lt;em&gt;UPDATE&lt;/em&gt;, &lt;em&gt;DELETE&lt;/em&gt; i &lt;em&gt;MERGE&lt;/em&gt;. Nie można używać wskazówek w podzapytaniach. Jeżeli wiele zapytań jest powiązanych operacją UNION to można użyć klauzuli &lt;em&gt;OPTION&lt;/em&gt; dopiero po ostatnim zapytaniu. Można używać wskazówek zapytań w klauzuli &lt;em&gt;INSERT&lt;/em&gt; za wyjątkiem przypadku w którym używamy wewnątrz wyrażenia &lt;em&gt;SELECT&lt;/em&gt;. Następujące wskazówki zapytań są obsługiwane przez &lt;em&gt;SQL Serwer 2012&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;{ HASH | ORDER } GROUP&lt;/li&gt;
&lt;li&gt;{ CONCAT | HASH | MERGE } UNION&lt;/li&gt;
&lt;li&gt;{ LOOP | MERGE | HASH } JOIN&lt;/li&gt;
&lt;li&gt;EXPAND VIEWS&lt;/li&gt;
&lt;li&gt;FAST number_rows&lt;/li&gt;
&lt;li&gt;FORCE ORDER&lt;/li&gt;
&lt;li&gt;IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX&lt;/li&gt;
&lt;li&gt;KEEP PLAN&lt;/li&gt;
&lt;li&gt;KEEPFIXED PLAN&lt;/li&gt;
&lt;li&gt;MAXDOP number_of_processors&lt;/li&gt;
&lt;li&gt;MAXRECURSION number&lt;/li&gt;
&lt;li&gt;OPTIMIZE FOR ( @variable_name { UNKNOWN | = literal_constant } [ ,...n ] )&lt;/li&gt;
&lt;li&gt;OPTIMIZE FOR UNKNOWN&lt;/li&gt;
&lt;li&gt;PARAMETERIZATION { SIMPLE | FORCED }&lt;/li&gt;
&lt;li&gt;RECOMPILE&lt;/li&gt;
&lt;li&gt;ROBUST PLAN&lt;/li&gt;
&lt;li&gt;USE PLAN N'xml_plan'&lt;/li&gt;
&lt;li&gt;TABLE HINT ( exposed_object_name [ , &amp;lt;table_hint&amp;gt; [ [, ]...n ] ]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Szczegółowe wytłumaczenie działania każdej wskazówki można znaleźć na stronie &lt;a rel="noopener" href="http://msdn.microsoft.com/en-us/library/ms181714.aspx" target="_blank"&gt;Books online&lt;/a&gt;. Poniższe dwa zapytania zwracają ten sam zagregowany zbiór wynikowy. Pierwsze zapytanie pozwala zdecydować &lt;em&gt;SQL Serwerowi&lt;/em&gt; jakiej techniki agregacji ma użyć natomiast drugie wymusza użycie operatora&lt;em&gt; Stream Aggregate&lt;/em&gt;.&lt;/p&gt;
&lt;pre class="sql"&gt;-- Hash match aggregate
SELECT qty, COUNT(*) AS num
FROM Sales.OrderDetails
GROUP BY qty;
-- Forcing stream aggregate
SELECT qty, COUNT(*) AS num
FROM Sales.OrderDetails
GROUP BY qty
OPTION (ORDER GROUP);
&lt;/pre&gt;
&lt;p&gt;Plan wykonania: &lt;a href="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep00001.png"&gt;&lt;img class="aligncenter size-medium wp-image-527" src="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep00001-300x116.png" alt="ep00001" width="300" height="116" /&gt;&lt;/a&gt; Drugie zapytanie używa operatora &lt;em&gt;Stream Aggregate&lt;/em&gt;, jednakże ponieważ ten operator wymaga posortowanych wejść to &lt;em&gt;SQL Serwer&lt;/em&gt; dodał dodatkowo operator &lt;em&gt;Sort&lt;/em&gt; do planu wykonania. Pomimo tego, że agregacja strumieniowa może być szybsza od agregacji skrótu to drugie zapytanie jest wolniejsze ponieważ musi posortować wejścia. Można dać wskazówkę dla pojedynczej tabeli w zapytaniu. Wskazówki tabel zawierają blokowanie i metody dostępu do pojedynczej tabeli lub widoku. Wskazówki tabel używamy w klauzuli FROM poprzedzając je słowem kluczowym &lt;em&gt;WITH&lt;/em&gt;. &lt;em&gt;SQL Serwer&lt;/em&gt; obsługuje następujące wskazówki tabel:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;NOEXPAND&lt;/li&gt;
&lt;li&gt;INDEX ( index_value [ ,...n ] ) | INDEX = ( index_value )&lt;/li&gt;
&lt;li&gt;FORCESEEK [ ( index_value ( index_column_name [ ,... ] ) ) ]&lt;/li&gt;
&lt;li&gt;FORCESCAN&lt;/li&gt;
&lt;li&gt;FORCESEEK&lt;/li&gt;
&lt;li&gt;KEEPIDENTITY&lt;/li&gt;
&lt;li&gt;KEEPDEFAULTS&lt;/li&gt;
&lt;li&gt;IGNORE_CONSTRAINTS&lt;/li&gt;
&lt;li&gt;IGNORE_TRIGGERS&lt;/li&gt;
&lt;li&gt;HOLDLOCK&lt;/li&gt;
&lt;li&gt;NOLOCK&lt;/li&gt;
&lt;li&gt;NOWAIT&lt;/li&gt;
&lt;li&gt;PAGLOCK&lt;/li&gt;
&lt;li&gt;READCOMMITTED&lt;/li&gt;
&lt;li&gt;READCOMMITTEDLOCK&lt;/li&gt;
&lt;li&gt;READPAST&lt;/li&gt;
&lt;li&gt;READUNCOMMITTED&lt;/li&gt;
&lt;li&gt;REPEATABLEREAD&lt;/li&gt;
&lt;li&gt;ROWLOCK&lt;/li&gt;
&lt;li&gt;SERIALIZABLE&lt;/li&gt;
&lt;li&gt;SPATIAL_WINDOW_MAX_CELLS = integer&lt;/li&gt;
&lt;li&gt;TABLOCK&lt;/li&gt;
&lt;li&gt;TABLOCKX&lt;/li&gt;
&lt;li&gt;UPDLOCK&lt;/li&gt;
&lt;li&gt;XLOCK&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Szczegółowe wytłumaczenie działania każdej wskazówki można znaleźć na stronie &lt;a rel="noopener" href="http://msdn.microsoft.com/en-us/library/ms187373.aspx" target="_blank"&gt;Books online&lt;/a&gt;. Prawdopodobnie najbardziej popularną wskazówką jet taka która wymusza użycie konkretnego indeksu. Poniżej znajdują się dwa zapytania z których pierwsze pozwala optymalizatorowi na wybór metody dostępu a drugie wymusza użycie indeksu nieklastrowanego.&lt;/p&gt;
&lt;pre class="sql"&gt;-- Clustered index scan
SELECT orderid, productid, qty
FROM Sales.OrderDetails
WHERE productid BETWEEN 10 AND 30
ORDER BY productid;
-- Forcing a nonclustered index usage
SELECT orderid, productid, qty
FROM Sales.OrderDetails WITH (INDEX(idx_nc_productid))
WHERE productid BETWEEN 10 AND 30
ORDER BY productid;
&lt;/pre&gt;
&lt;p&gt;Plan wykonania: &lt;a href="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep00002.png"&gt;&lt;img class="aligncenter size-medium wp-image-528" src="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep00002-300x226.png" alt="ep00002" width="300" height="226" /&gt;&lt;/a&gt; &lt;em&gt;SQL Serwer&lt;/em&gt; obsługuje następujące wskazówki złączeń:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LOOP&lt;/li&gt;
&lt;li&gt;HASH&lt;/li&gt;
&lt;li&gt;MERGE&lt;/li&gt;
&lt;li&gt;REMOTE&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Szczegółowe wytłumaczenie działania każdej wskazówki można znaleźć na stronie &lt;a rel="noopener" href="http://msdn.microsoft.com/en-us/library/ms173815.aspx" target="_blank"&gt;Books online&lt;/a&gt;. Poniższe dwa zapytania zwracają ten sam zbiór wynikowy. Pierwsze zapytanie pozwala zdecydować &lt;em&gt;SQL Serwerowi&lt;/em&gt; jakiego algorytmu złączenia użyć natomiast drugie wymusza użycie operatora &lt;em&gt;merge join&lt;/em&gt;.&lt;/p&gt;
&lt;pre class="sql"&gt;-- Nested loops join
SELECT O.custid, O.orderdate, OD.orderid, OD.productid,OD.qty
FROM Sales.Orders AS O
INNER JOIN Sales.OrderDetails AS OD
ON O.orderid = OD.orderid
WHERE O.orderid &amp;lt; 10250;
-- Forced merge join
SELECT O.custid, O.orderdate, OD.orderid, OD.productid,OD.qty
FROM Sales.Orders AS O
INNER MERGE JOIN Sales.OrderDetails AS OD
ON O.orderid = OD.orderid
WHERE O.orderid &amp;lt; 10250;
&lt;/pre&gt;
&lt;p&gt;Plan wykonania: &lt;a href="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep00003.png"&gt;&lt;img class="aligncenter size-medium wp-image-529" src="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep00003-300x262.png" alt="ep00003" width="300" height="262" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Plan Guides&lt;/h2&gt;
&lt;p&gt;W przewodnikach planu można określić albo klauzulę &lt;em&gt;OPTION&lt;/em&gt; albo plan wykonania dla wyrażenia które optymalizujesz. Taki przewodnik musi zawierać również wyrażenie &lt;em&gt;T-SQL&lt;/em&gt; dla którego jest tworzone aby optymalizator mógł porównać zapytanie z zapisanym w przewodniku wyrażeniem. Przewodników planu wykonania nie można używać w wersji &lt;em&gt;SQL Serwer 2012 Express&lt;/em&gt;. Można utworzyć następujące typy przewodników planu:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OBJECT&lt;/strong&gt; - są używane przez optymalizator do dopasowania zapytań wewnątrz procedur składowanych, funkcji skalarnych użytkownika, funkcji tablicowych oraz wyzwalaczy &lt;em&gt;DML&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQL&lt;/strong&gt; - są używane przez optymalizator do dopasowania samodzielnych zapytań.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TEMPLATE &lt;/strong&gt;- są używane przez optymalizator do optymalizacji samodzielnych zapytań które mogą być parametryzowane.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Przewodniki planu tworzymy za pomocą procedury systemowej &lt;em&gt;sys.sp_create_plan_guide&lt;/em&gt;. Przewodnik można wyłączyć, włączyć lub usunąć za pomocą procedury systemowej &lt;em&gt;sys.sp_control_plan_guide&lt;/em&gt;. Można utworzyć przewodnik z zapisanego w pamięci planu wykonania za pomocą procedury systemowej &lt;em&gt;sys.sp_create_plan_guide_from_handle&lt;/em&gt;. Za pomocą funkcji systemowej &lt;em&gt;sys.fn_validate_plan_guide&lt;/em&gt; można sprawdzić poprawność przewodnika planu. Przewodnik może być niepoprawny po zmianach w schemacie bazy danych. Aby pobrać sparametryzowaną wersję zapytania można użyć procedury systemowej &lt;em&gt;sys.sp_get_query_template&lt;/em&gt;. Ta procedura jest szczególnie przydatna przy tworzeniu przewodników &lt;em&gt;TEMPLATE&lt;/em&gt;. Rozważmy następującą procedurę składowaną:&lt;/p&gt;
&lt;pre class="sql"&gt;CREATE PROCEDURE Sales.GetCustomerOrders
(@custid INT)
AS
SELECT orderid, custid, empid, orderdate
FROM Sales.Orders
WHERE custid = @custid;
&lt;/pre&gt;
&lt;p&gt;Dla zdecydowanej większości klientów, np klienta z identyfikatorem 71 zapytanie w procedurze nie jest bardzo selektywne dlatego skan tabeli lub indeksu klastrowanego jest najlepszym rozwiązaniem. Jednakże dla pewnej ilości klientów z tylko kilkoma zamówieniami wyszukanie w indeksie  jest lepsze np dla klienta o identyfikatorze 13. Jeżeli użytkownik pierw wykona procedurę dla klienta 13 to zapisany w pamięci plan wykonania nie będzie odpowiedni dla większości klientów. Tworząc przewodnik planu który będzie używał wskazówki zapytania która wymusi optymalizację dla klienta 71 zoptymalizujemy procedurę dla większości klientów. Poniższy kod tworzy taki przewodnik planu:&lt;/p&gt;
&lt;pre class="sql"&gt;EXEC sys.sp_create_plan_guide
@name = N'Cust71',
@stmt = N'
SELECT orderid, custid, empid, orderdate
FROM Sales.Orders
WHERE custid = @custid;',
@type = N'OBJECT',
@module_or_batch = N'Sales.GetCustomerOrders',
@params = NULL,
@hints = N'OPTION (OPTIMIZE FOR (@custid = 71))';
&lt;/pre&gt;
&lt;p&gt;Jeżeli wykonamy procedurę z różnymi parametrami po wyczyszczeniu pamięci aby mieć pewność, że stary plan nie jest zapisany w pamięci to SQL Serwer zawsze zoptymalizuje zapytanie dla wartości kolumny &lt;em&gt;custid&lt;/em&gt; równej 71 i użyje skanowania indeksu klastrowanego.  Wykonajmy zapytanie dla wartości 13 i  71 i sprawdźmy plan wykonania:&lt;/p&gt;
&lt;pre class="sql"&gt;-- Clearing the cache
DBCC FREEPROCCACHE;
-- Executing the procedure with different parameters
EXEC Sales.GetCustomerOrders @custid = 13;
EXEC Sales.GetCustomerOrders @custid = 71;
&lt;/pre&gt;
&lt;p&gt;Plan wykonania: &lt;a href="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep112211.png"&gt;&lt;img class="aligncenter size-medium wp-image-532" src="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep112211-300x124.png" alt="ep112211" width="300" height="124" /&gt;&lt;/a&gt; Listę przewodników zapytań bazy danych możemy zobaczyć używając widoku &lt;em&gt;sys.plan_guides&lt;/em&gt;. Można również podejrzeć listę wskazówek użytych w każdym przewodniku planu jak w poniższym zapytaniu:&lt;/p&gt;
&lt;pre class="sql"&gt;SELECT plan_guide_id
,NAME
,scope_type_desc
,is_disabled
,query_text
,hints
FROM sys.plan_guides;
&lt;/pre&gt;
&lt;p&gt;Poniższy kod czyści bazę danych:&lt;/p&gt;
&lt;pre class="sql"&gt;EXEC sys.sp_control_plan_guide N'DROP', N'Cust71';
DROP PROCEDURE Sales.GetCustomerOrders;
&lt;/pre&gt;
&lt;h2&gt;Ćwiczenia&lt;/h2&gt;
&lt;h3&gt;I. Stworzenie procedury ze wskazówką RECOMPILE&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Otwórz nowe okno &lt;em&gt;SSMS&lt;/em&gt; i ustaw kontekst bazy danych na bazę danych &lt;em&gt;TSQL2012&lt;/em&gt;.
&lt;pre class="sql"&gt;USE TSQL2012
GO
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Napisz procedurę składowaną pobierającą wszystkie zamówienia dla pojedynczego klienta. Użyj klauzuli OPTION do wymuszenia rekompilacji. Zauważ, że realna procedura może zawierać wiele instrukcji i rekompilacja całej procedury może nie być najlepszym rozwiązaniem. Użycie przewodnika planu może również nie być najlepszym rozwiązaniem ponieważ plan z przewodnika może nie być najwydajniejszym planem dla wszystkich wartości parametru wejściowego. Wskazówka zapytania może być w takim wypadku najlepsza.
&lt;pre class="sql"&gt;CREATE PROCEDURE Sales.GetCustomerOrders
(@custid INT)
AS
SELECT orderid, custid, empid, orderdate
FROM Sales.Orders
WHERE custid = @custid
OPTION (RECOMPILE);
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Przetestuj procedurę z wartościami 13 i 71 i przejrzyj plan wykonania zapytań.
&lt;pre class="sql"&gt;EXEC Sales.GetCustomerOrders @custid = 13;
EXEC Sales.GetCustomerOrders @custid = 71;
&lt;/pre&gt;
Plan wykonania: &lt;a href="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep_1.png"&gt;&lt;img class="aligncenter size-medium wp-image-534" src="http://www.smsoft.pl/blog/wp-content/uploads/2014/01/ep_1-300x197.png" alt="ep_1" width="300" height="197" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Wyczyść bazę danych.
&lt;pre class="sql"&gt;DROP PROCEDURE Sales.GetCustomerOrders;
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Podsumowanie&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Można wymusić wykonanie zapytania w specyficzny sposób za pomocą wskazówek optymalizatora.&lt;/li&gt;
&lt;li&gt;Używając przewodników zapytań można wymusić odpowiednie wykonanie zapytania bez jego modyfikacji.&lt;/li&gt;
&lt;/ol&gt;</description>
      <pubDate>Sun, 26 Jan 2014 13:38:12 Z</pubDate>
      <a10:updated>2014-01-26T13:38:12Z</a10:updated>
    </item>
  </channel>
</rss>