struct (C# Reference)
Visual Studio 2008
A struct type is a value type that is typically used to encapsulate small groups of related variables, such as the coordinates of a rectangle or the characteristics of an item in an inventory. The following example shows a simple struct declaration:
public struct Book
{
public decimal price;
public string title;
public string author;
}
Structs can also contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types, although if several such members are required, you should consider making your type a class instead.
Structs can implement an interface but they cannot inherit from another struct. For that reason, struct members cannot be declared as protected.
For more information, see Structs (C# Programming Guide).
???
I realy don't get "struct", is to saying its for holding vars, what is it for?
CS Team: You probably would get a faster response to you question by posting it in the forums. You can find the C# Language Forum here: http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/threads .
CS Team: You probably would get a faster response to you question by posting it in the forums. You can find the C# Language Forum here: http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/threads .
[tfl - 10 10 10] Hi - and thanks for your post.You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn. You are much more likely get a quick response
using the forums than through the Community Content.
For specific help about:
.Net Development : http://social.msdn.microsoft.com/Forums/en-US/category/visualstudio
Open Specifications : http://social.msdn.microsoft.com/Forums/en-US/category/openspecifications
SharePoint 2010 : http://social.msdn.microsoft.com/Forums/en-US/category/sharepoint2010
SQL : http://social.msdn.microsoft.com/Forums/en-US/category/sqlserver
Visual Studio : http://social.msdn.microsoft.com/Forums/en-US/category/visualstudio
- 11/1/2009
- Gigabyte Productions
- 10/10/2010
- Thomas Lee
A little about C# struct
A struct is meant to hold data of different types in a single data block.
So if you want to define a single datatype that holds all the data of a driver's license (name (string), DOB (date), height (double), personal photo (image)...etc) then one efficient way of doing it would be defining a struct with all the data pieces in it and accessing it as a single data block with different variables of different data types defined inside it.
So if you want to define a single datatype that holds all the data of a driver's license (name (string), DOB (date), height (double), personal photo (image)...etc) then one efficient way of doing it would be defining a struct with all the data pieces in it and accessing it as a single data block with different variables of different data types defined inside it.
- 9/17/2010
- SaudiIntellect
- 10/10/2010
- Thomas Lee