codecandle logo




 

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


Related: C# Tutorial

Date: 30.04.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: articles

Reference resources: 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)
  • comment icon
  • Comments Section
 
  • 18.12.2013 09:39:50 post by vpZAd

kOa2tv

  • 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.