I.T. Discussion Community!
-Collapse +Expand
C#
Search C# Group:

Advanced
-Collapse +Expand C# To/From
To/FromCODEGuides
-Collapse +Expand C# Study Test
PRESTWOODCERTIFIED
-Collapse +Expand C# Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► KBC# Knowledge Base  Print This    All Groups  

C# (Visual C# & VS.Net) Tech Articles

These Articles are contributed by you (our online community members). They are organized by our knowledge base topics. Specifically, by the C# sub-topics.

Contribute an Article

24 C# (Visual C# & VS.Net) Articles

Group: C# (Visual C# & VS.Net)


Topic: C#

This will show how to make a "hello world" console application in Visual Studio 2008 with C#. Let VS.Net do the work and create a new console application using the menu. Use Console.WriteLine and Console.ReadLine for simple input and output.

Posted By Bryan Valencia, Post #101322, KB Topic: C#
  +Add Comment

Using aspnet_regsql.exe to set up a database to support the functionality of ASP.NET 2.0's built-in membership.
Posted By Stephen Berry, Post #101291, KB Topic: C#
  +Add Comment  (1 Comments)

A basic introduction to deploying an application using Visual Studio .NET 2005's ClickOnce
Posted By Adam Lum, Post #100507, KB Topic: C#
  +Add Comment  (1 Comments)

If you've been around computing for any length of time, you know you can quickly spend a lot of money on those $60, five-pound reference books. For just ten dollars more, you can get your hands on over 500 great training videos for Visual Studio .NET.
Posted By Wes Peterson, Post #100640, KB Topic: C#
  +Add Comment




Topic: Tool Basics

C# is case sensitive. The following does NOT:

messagebox.Show("hello");  //Does not work!

The first time you type any other case for commands or variables, VS.Net will change it to the accepted or defined case. For example, if you type messagebox.show it is converted to MessageBox.Show. Once corrected, you can break it again by editing MessageBox to messagebox and the compiler will give you an error.

Posted By Mike Prestwood, Post #101336, KB Topic: Tool Basics
  +Add Comment




Topic: Language Basics

Boxing is the conversion of a value type to the object type (or to any interface type that is implemented by the value type). Unboxing is the conversion from an object type to a value type (or from an interface type to any value type that is implemented by the value type).

Posted By Stephen Berry, Post #101285, KB Topic: Language Basics
  +Add Comment




Topic: Language Details

A quick example to demonstrate the yield keyword in the .NET Framework

Posted By Adam Lum, Post #100539, KB Topic: Language Details
  +Add Comment




Topic: OOP

C# supports abstract class members and abstract classes using the abstract modifier. An abstract class is a class with one or more abstract members and you cannot instantiate an abstract class. However, you can have additional implemented methods and properties. An abstract member is either a method (implicitly virtual), property, indexer, or event in an abstract class. You can add abstract members ONLY to abstract classes using the abstract keyword.

Posted By Mike Prestwood, Post #101344, KB Topic: OOP
  +Add Comment

In C#, you use the class keyword to specify a class and you signify its parent with a colon and the name of the parent class. When you instantiate an object from a class, you use the new keyword.

Posted By Mike Prestwood, Post #101399, KB Topic: OOP
  +Add Comment

In C#, a constructor is called whenever a class or struct is created. A constructor is a method with the same name as the class with no return value and you can overload the constructor. If you do not create a constructor, C# will create an implicit constructor that initializes all member fields to their default values.

Constructors can execute at two different times. Static constructors are executed by the CLR before any objects are instantiated. Regular constructors are executed when you create an object.

Posted By Mike Prestwood, Post #101819, KB Topic: OOP
  +Add Comment

Use a destructor to free unmanaged resources. A destructor is a method with the same name as the class but preceded with a tilde (as in ~ClassName). The destructor implicity creates an Object.Finalize method (you cannot directly call nor override the Object.Finalize method).

In C# you cannot explicitly destroy an object. Instead, the .Net Frameworks garbage collector (GC) takes care of destroying all objects. The GC destroys the objects only when necessary. Some situations of necessity are when memory is exhausted or you explicitly call the System.GC.Collect method. In general, you never need to call  System.GC.Collect.

Posted By Mike Prestwood, Post #101834, KB Topic: OOP
  +Add Comment

Classes and structs can inherit from interfaces in a manner similar to how classes can inherit a base class or struct, but a class or struct can inherit more than one interface and it inherits only the method names and signatures, because the interface itself contains no implementations.

class MyClass: IMyInterface
{  
  public object Clone()
{
return null;
}

// IMyInterface implemented here...
}
Posted By Mike Prestwood, Post #101435, KB Topic: OOP
  +Add Comment

In C# you can set the visibility of a member field to any visibility: private, protected, public, internal or protected internal. You can intialize a member field with a default when declared. If you set the member field value in your constructor, it will override the default value. Finally, you can use the static modifier (no instance required) and readonly modifier (similar to a constant).

Posted By Mike Prestwood, Post #101744, KB Topic: OOP
  To/From Code Guide: C# Member Method... vs. Other Languages
  +Add Comment  (1 Comments)

In C#, parens indicate a method and the lack of parens indicate a property. You use special get and set methods to both get and set the values of properties. For a read-only property, leave out the set method. The value keyword is used to refer to the member field. Properties can make use of any of the access modifiers (private, protected, etc). It is common to use a lowercase member names for member fields ("name" in our example) and uppercase properties to manage member fields ("Name" in our example).

Posted By Mike Prestwood, Post #101738, KB Topic: OOP
  +Add Comment

Method overriding allows you to define or implement a virtual method in a parent class and then replace it in a descendant class. In C#, you specify a virtual method with the virtual keyword in a parent class and replace it in a descendant class using the override keyword.

Posted By Mike Prestwood, Post #101472, KB Topic: OOP
  +Add Comment  (1 Comments)

C# uses the keyword partial to specify a partial class. All parts must be in the same namespace.

A partial class, or partial type, is a class that can be split into two or more source code files and/or two or more locations within the same source file. Each partial class is known as a class part or just a part. Logically, partial classes do not make any difference to the compiler. The compiler puts the class together at compile time and treats the final class or type as a single entity exactly the same as if all the source code was in a single location.

You can use them for many things including to separate code generator code, organize large classes, divice a class up so you can split ownwership among multiple developers, have different versions of the same class, and to utilize multiple languages with a single class.

Posted By Mike Prestwood, Post #101807, KB Topic: OOP
  +Add Comment  (1 Comments)

Add new methods to predefined types and objects with extension methods (no need to recompile the base code).  To use this extension, all i have to do is include the  namespace ExtensionExample.

Posted By khemebuen, Post #101992, KB Topic: OOP
  +Add Comment




Topic: WinForms

The ButtonsCS project. Create a classic "Hello, World" application using Visual Studio .Net with C# syntax. Requires either the full version or Visual C# Express Edition.

Posted By Mike Prestwood, Post #101212, KB Topic: WinForms
  +Add Comment




Topic: WebForms Coding Tasks

This article describes the ASPX file extensions.
Posted By Mike Prestwood, Post #100034, KB Topic: WebForms Coding Tasks
  +Add Comment

To restrict what an ASP.NET application can and cannot access and to provide an additional level of application isolation in a hosted environment, access security can be used. You do this by configuring the element in the machine-level Web.config file located in the following folder: %windir%\Microsoft.NET\Framework\{version}\CONFIG.

Posted By Adam Lum, Post #100385, KB Topic: WebForms Coding Tasks
  +Add Comment  (75 Comments)

Every now and then you want a link to open not only in a new browser, but you may want to give the new window the appearance of a pop-up window. This ASP/Javascript method gives you a lot of control and is easy to figure out and implement.
Posted By Bryan Valencia, Post #100853, KB Topic: WebForms Coding Tasks
  +Add Comment  (1 Comments)

Visual web developer offers a few different ways to add dynamic content to a web page. This will help you choose which one is right for your application. In General, there are Data-Aware components, Labels, and PlaceHolders.
Posted By Bryan Valencia, Post #101680, KB Topic: WebForms Coding Tasks
  +Add Comment

This article will show how to access a function in a legacy COM dll from a ASP.NET web page. By legacy I mean a dll that is not a .NET managed code dll (a Win32 DLL). 

Posted By Bryan Valencia, Post #102075, KB Topic: WebForms Coding Tasks
  +Add Comment

When designing a WinForms application, the most straightforward way to authenticate a user is using NTLM or Active Directory using WindowsIdentity.GetCurrent. Over the Internet, you can use the whole ASP.Net security setup with Membership.GetUser. The GenericPrincipal object works well when you deploy to a mixed web/WinForms environment. See new GenericIdentity.

Posted By Bryan Valencia, Post #102068, KB Topic: WebForms Coding Tasks
  +Add Comment

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech