Codecandle Programming Articles...

Advanced Article Search
  • April 2013: Microsoft released Enterprise Library 6 (MSDN news)
  • April 2013: Google launched Chrome 27 on the Beta channel(Google Developers)
  • 14/03/2012 SQL Server 2012 RTM Trial Available Now.
  • Visual C++ 11 Beta is announced...
  • Visual Studio 11 Beta Released...
  • Microsoft announced availability of Windows 8 Consumer preview
  • Microsoft® SQL Server 2012 Evaluation is available for download.

Country/Region: [ Select ]

Subject Of Week: Aritificial Intelligence in Programming...
Survey of Month: What do you think about Microsoft SQL Server 2012...
Upcoming Developer Events: (Msevents) Windows Phone 7.x Upgrade Lab (Starts Friday, May 03, 2013 8:30 AM - Ends: Friday, May 03, 2013 5:00 PM)
Tip of week: Sealed Classes in C# can not be inherited by derived Classes...
Recent download release: Windows Azure SDK 2.0 for .NET
Recent released developer books: Android Design Patterns: Interaction Design Solutions for Developers
Post an Article




 

C# - Functions - Variable Scope - Global Variables - Struct Functions



Related: C# Tutorial

Date: Nisan 30, 2011


Structs can contain functions. Variables in Struct does not require to be defined as Static for global access for functions within Struct.


namespace NS1
{
class Program
{
struct Counties
{
//struct function doesnt require static keyword
public string countyName;
public string stateName;

public string mergedName()
{
return countyName + " is a county of " + stateName; //OK: accessible
}

}

static void Main(string [] args)
{
Counties st_county_1 = new Counties();
st_county_1.countyName = "dakota";
st_county_1.stateName = "nebraska";

Console.WriteLine(st_county_1.mergedName());
}
}
}

C# - Functions - Variable Scope - Global Variables - Struct Functions

Area: C# Tutorials

MSDN details: http://msdn.microsoft.com/en-us/library/ah19swz4%28VS.71%29.aspx


Tags: C# - variable scope - struct functions - non static global variables of struct functions

Catagory layer 1: Programming
Catagory layer 2: Languages

Code layer 1: Languages
Code layer 2: Csharp
Code layer 3: C# 1.0
Code layer 4: Functions
Code layer 5: Variable-Scop-Struct-Functions

Reader layer 1: beginner

Sector layer 1: C# Programmer

Fuzzy layer 1: C# Language Reference
Fuzzy layer 2: C# struct functions

Nodes: Languages\C# (1)
Viewed: 920
  • Comments Section
  • Post your Comment:


Chat section


[ Copy this | Start New | Full Size ]

CodeCandle

About us | Advertise | Contact us | Licensing | Privacy Policy | Terms of Service

© 2010 CodeCandle. All rights reserved.