Difference between revisions of "OOP Class14"
esse quam videri
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >") |
|||
Line 7: | Line 7: | ||
for | for | ||
− | <csharp> | + | <syntaxhighlight lang="csharp" line="1" > |
long count = 200000000; | long count = 200000000; | ||
short[] shorts = new short[count]; | short[] shorts = new short[count]; | ||
Line 33: | Line 33: | ||
==Async== | ==Async== | ||
http://msdn.microsoft.com/en-us/library/hh191443.aspx | http://msdn.microsoft.com/en-us/library/hh191443.aspx | ||
− | <csharp> | + | <syntaxhighlight lang="csharp" line="1" > |
private void buttonBlock_Click(object sender, EventArgs e) | private void buttonBlock_Click(object sender, EventArgs e) | ||
{ | { | ||
Line 66: | Line 66: | ||
===write file=== | ===write file=== | ||
− | <csharp> string fileName = "test.txt"; | + | <syntaxhighlight lang="csharp" line="1" > string fileName = "test.txt"; |
string folderPath = "c:\\user\\"; | string folderPath = "c:\\user\\"; | ||
Line 90: | Line 90: | ||
===read file=== | ===read file=== | ||
− | <csharp> StreamReader sr = new StreamReader(fs); | + | <syntaxhighlight lang="csharp" line="1" > StreamReader sr = new StreamReader(fs); |
while( sr.Peek() > -1 ) | while( sr.Peek() > -1 ) | ||
{ | { | ||
Line 105: | Line 105: | ||
===Send Mail=== | ===Send Mail=== | ||
− | <csharp><% @Page Language="C#" %> | + | <syntaxhighlight lang="csharp" line="1" ><% @Page Language="C#" %> |
<% @Import Namespace="System.Web.Mail" %> | <% @Import Namespace="System.Web.Mail" %> | ||
<% | <% | ||
Line 152: | Line 152: | ||
multipart form | multipart form | ||
− | <csharp> | + | <syntaxhighlight lang="csharp" line="1" > |
<form enctype="multipart/form-data" runat="server"> | <form enctype="multipart/form-data" runat="server"> | ||
<tr> | <tr> | ||
Line 170: | Line 170: | ||
Parse the multipart form and save the file msdn library. System.Web.HtmlInputFile.PostedFile Property | Parse the multipart form and save the file msdn library. System.Web.HtmlInputFile.PostedFile Property | ||
− | <csharp> | + | <syntaxhighlight lang="csharp" line="1" > |
void btnUploadTheFile_Click(object Source, EventArgs evArgs) | void btnUploadTheFile_Click(object Source, EventArgs evArgs) | ||
{ | { |
Revision as of 18:28, 25 January 2016
Parallel
http://msdn.microsoft.com/en-us/library/dd460713(v=vs.110).aspx
samples: http://code.msdn.microsoft.com/windowsdesktop/Samples-for-Parallel-b4b76364
for <syntaxhighlight lang="csharp" line="1" > long count = 200000000; short[] shorts = new short[count]; for (long i = 0; i < count; i++)
{ shorts[i] = 1; }
</pre>
Parallel.For
short[] shortsP = new short[count]; Parallel.For(0, count, i => { shortsP[i] = 1; }); </csharp> Demo http://iam.colum.edu/oop/classsource/class15/AsyncConsoleApplication.zip http://iam.colum.edu/oop/classsource/class15/WindowsFormsApplicationAsync.zipAsync
http://msdn.microsoft.com/en-us/library/hh191443.aspx <syntaxhighlight lang="csharp" line="1" > private void buttonBlock_Click(object sender, EventArgs e)
{ textBox1.Text = DoLongCount(); }//Async call to async method private async void buttonAsync_Click(object sender, EventArgs e) { textBox1.Text = await DoLongAsyncCount(); }private string DoLongCount() { System.Threading.Thread.Sleep(1000); Count++; return "count is " + Count; }//Async Task private async Task<string> DoLongAsyncCount() { await Task.Delay(1000); Count++; return "count is " + Count; }</csharp>
Final Review
- Be very familiar with c# syntax
- Basic object types (int, bool, string)
- Conditional and Branching statements
- Arrays and Generics ie List
- Understand Classes and Inheritance.
- Use some advanced class features such as abstract classes and virtual methods that are overridden
- Understand class relationships
- Is A
- Has A
- Uses A
- Understand Encapsulation, Abstraction and Polymorphism
- Abstraction
- Each class should abstract its behavior in order to increase usability, reuse, and organization.
- Encapsulation
- Each class should contain all of the properties and methods it needs. It should only expose what is necessary to outside classes.
- Polymorphism
- many forms, same code interface but interchangeable classes
- Be able to read and create UML Diagrams
- Be able to recognize and use simple design patters