C#
  Home arrow C# arrow C# Methods, part 1
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# Methods, part 1
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 35
    2005-04-26

    Table of Contents:
  • C# Methods, part 1
  • Method Signature
  • Instance Methods
  • Static Methods
  • Methods and StackFrame
  • Methods Overloading

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# Methods, part 1


    (Page 1 of 6 )

    In this article, you will learn about C# methods (functions), which form the behavior of your classes. C# does not have global functions, but it does have code encapsulation; you will learn how these and other Object Oriented Programming concepts and principles affect what you can do in C#.

    C# classes carry their data in the form of fields (private fields, most of the time) and process the data using methods (functions). Methods in C# form the behavior of your class, so the class Employee may have a method called RaiseSalary that raises the salary of the employee based on his/her position in the company.

    In C# there are no global functions (a C++ concept), and your methods must exist in the context of a class or struct. What's really interesting is that, when you develop a class and compile it, the other programmers who use it do not need to know anything about how you developed your methods and what happens inside each method; this called code encapsulation. So your algorithms and code are hidden (almost because they can use reverse engineering to know what's going on, but this is not the point now) from the client code.

    C# is not case sensitive, so you can have a method called GetSalary() and another one called getsalary(); it doesn't make sense, but this code will compile. Please avoid doing this in your code, though, because it's a bad class design concept. Name your C# methods depending on the process they do.

    For example, if you have two methods that update some data, and one of them updates a database and the other updates a file, you can name them UpdateDB() and UpdateFile() respectively. Naming your methods is an important issue in Object Oriented Programming concepts, and you should spend some time doing so in your analysis and design phase.

    More C# Articles
    More By Michael Youssef


     

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek