BCIT : COMP 2870 Day 2

 

The instructor covered more of bare bones C# stuff.  To tell you the truth, this is how I taught myself C# as well.  I opened up notepad and started typing.  Copied examples from online sources (the few that was available back then), and use the csc.exe compiler to start compiling down my code.  I think this process is great for everyone to understand.  It really shows them the background of what VS.NET hides from you, and what options that may not be so visible in that IDE.

 

Allot of the OOP specific keywords were covered.  sealed, inheritance, override, virtual, new, abstract, base, this, interfaces, the is operator, const vs readonly, arrays, switch (cascading rules), break, documentation generation, commenting, foreach, System.Convert, try/catch/finally, looping constructs, string class, tryparse(), using “@” with string literals, System.IO, MapPath(), reading and writing text files, close, dispose, file uploading; The “Main” entry point in a console application.  A simple windows form application, which shows a basic MesageBox.

 

Next they got an introduction to some of the more common .NET Namespaces, and what the heck namespaces are in the first place! (think java packages).  Oh and how to import the assemblies with the “using” keyword and the /r switch on the compiler.

 

 

More information I felt could benefit the students

ref vs out : http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf (Section 8.3) 

 

Here are portions of that section:

 

            A reference parameter is used for “by reference” parameter passing, in which the parameter acts as an alias for a

            caller-provided argument. A reference parameter does not itself define a variable, but rather refers to the variable of

            the corresponding argument. Modifications of a reference parameter impact the corresponding argument. A

            reference parameter is declared with a ref modifier.

 

            The ref keyword shall be used in both the declaration of the formal parameter and in uses of it. The use of ref at the

            call site calls special attention to the parameter, so that a developer reading the code will understand that the value of

            the argument could change as a result of the call.

 

            An output parameter is similar to a reference parameter, except that the initial value of the caller-provided

            argument is unimportant. An output parameter is declared with an out modifier.

 

            For value, reference, and output parameters, there is a one-to-one correspondence between caller-provided

            arguments and the parameters used to represent them.

 

params keyword:

 

Also in Section 8.3 of the ECMA Specification

 

            A parameter array enables a many-to-one relationship: many arguments can be represented by a single parameter

            array. In other words, parameter arrays enable variable length argument lists.   A parameter array is declared with a

            params modifier. There can be only one parameter array for a given method, and it shall always be the last

            parameter specified. The type of a parameter array is always a single dimensional array type. A caller can either pass

            a single argument of this array type, or any number of arguments of the element type of this array type.

 

You can also find more on all three of these (out, ref, params),in more detail, in Section 17.5.1 of the spec.

 

When to call Dispose()

The easiest way to find out this answer is to go a quick google search: http://www.google.com/search?q=when+to+call+dispose  The recommended best practice is to ALWAYS call dispose.  So be careful and start watching out for the Dispose() method and call it!

 

aspnet_regiis

 

During the session we were shown a demo which the IIS Application was set to use v1.1 of the .NET Framework.  This class is focusing on v2, using Visual Studio 2005, so there was a big bad error on the overheard.  The instructor intentionally did this in order to show the students exactly what the error meant, and how to fix it.  He actually had to login as admin to modify IIS.  I wanted to add that the students could have simply used aspnet_regiis to fix the issue.  Dump to a DOS command prompt.  Make sure that the SDK binaries are in your path, or just use the “SDK Command Prompt” which should be in your start menu.  Type in “aspnet_regiis /?” to get a complete listing of all switch’s.

 

 

 

 

1 Comment

  • Emily said

    Hi Robert, thanks a lot for the links and posts. Is there a general course notes link that I can take a look at. I will probably take this course sometimes for interest. It'll be helpful if I could preview the course. Thanks again.

Comments have been disabled for this content.