Structure C#
Здравствуйте.
Суть проблемы в том что не знаю как обратится к переменной в структуре.
Я создал класс (он обязательно нужен).
В нем создал структуру.
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .csharp.geshi_code {font-family:monospace;} .csharp.geshi_code .imp {font-weight: bold; color: red;} .csharp.geshi_code .kw1 {color: #0600FF;} .csharp.geshi_code .kw2 {color: #FF8000; font-weight: bold;} .csharp.geshi_code .kw3 {color: #008000;} .csharp.geshi_code .kw4 {color: #FF0000;} .csharp.geshi_code .kw5 {color: #000000;} .csharp.geshi_code .co1 {color: #008080; font-style: italic;} .csharp.geshi_code .co2 {color: #008080;} .csharp.geshi_code .co3 {color: #008080;} .csharp.geshi_code .coMULTI {color: #008080; font-style: italic;} .csharp.geshi_code .es0 {color: #008080; font-weight: bold;} .csharp.geshi_code .es_h {color: #008080; font-weight: bold;} .csharp.geshi_code .br0 {color: #000000;} .csharp.geshi_code .sy0 {color: #008000;} .csharp.geshi_code .st0 {color: #666666;} .csharp.geshi_code .st_h {color: #666666;} .csharp.geshi_code .nu0 {color: #FF0000;} .csharp.geshi_code .me1 {color: #0000FF;} .csharp.geshi_code .me2 {color: #0000FF;} .csharp.geshi_code span.xtra { display:block; }
namespace ConsoleApplication4
{
class Structure
{
public struct S0001
{
uint keyLen;
byte[] Key;
byte AuthType;
int ServerVersion;
byte Bonus;
}
}
}
Потом обращаюсь к класу.
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .csharp.geshi_code {font-family:monospace;} .csharp.geshi_code .imp {font-weight: bold; color: red;} .csharp.geshi_code .kw1 {color: #0600FF;} .csharp.geshi_code .kw2 {color: #FF8000; font-weight: bold;} .csharp.geshi_code .kw3 {color: #008000;} .csharp.geshi_code .kw4 {color: #FF0000;} .csharp.geshi_code .kw5 {color: #000000;} .csharp.geshi_code .co1 {color: #008080; font-style: italic;} .csharp.geshi_code .co2 {color: #008080;} .csharp.geshi_code .co3 {color: #008080;} .csharp.geshi_code .coMULTI {color: #008080; font-style: italic;} .csharp.geshi_code .es0 {color: #008080; font-weight: bold;} .csharp.geshi_code .es_h {color: #008080; font-weight: bold;} .csharp.geshi_code .br0 {color: #000000;} .csharp.geshi_code .sy0 {color: #008000;} .csharp.geshi_code .st0 {color: #666666;} .csharp.geshi_code .st_h {color: #666666;} .csharp.geshi_code .nu0 {color: #FF0000;} .csharp.geshi_code .me1 {color: #0000FF;} .csharp.geshi_code .me2 {color: #0000FF;} .csharp.geshi_code span.xtra { display:block; }
Structure strct = new Structure();
А вот теперь как обратится например к переменной /** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .csharp.geshi_code {font-family:monospace;} .csharp.geshi_code .imp {font-weight: bold; color: red;} .csharp.geshi_code .kw1 {color: #0600FF;} .csharp.geshi_code .kw2 {color: #FF8000; font-weight: bold;} .csharp.geshi_code .kw3 {color: #008000;} .csharp.geshi_code .kw4 {color: #FF0000;} .csharp.geshi_code .kw5 {color: #000000;} .csharp.geshi_code .co1 {color: #008080; font-style: italic;} .csharp.geshi_code .co2 {color: #008080;} .csharp.geshi_code .co3 {color: #008080;} .csharp.geshi_code .coMULTI {color: #008080; font-style: italic;} .csharp.geshi_code .es0 {color: #008080; font-weight: bold;} .csharp.geshi_code .es_h {color: #008080; font-weight: bold;} .csharp.geshi_code .br0 {color: #000000;} .csharp.geshi_code .sy0 {color: #008000;} .csharp.geshi_code .st0 {color: #666666;} .csharp.geshi_code .st_h {color: #666666;} .csharp.geshi_code .nu0 {color: #FF0000;} .csharp.geshi_code .me1 {color: #0000FF;} .csharp.geshi_code .me2 {color: #0000FF;} .csharp.geshi_code span.xtra { display:block; }
keyLen
и задать ей значение?
Буду благодарен за ответы.
Суть проблемы в том что не знаю как обратится к переменной в структуре.
Я создал класс (он обязательно нужен).
В нем создал структуру.
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .csharp.geshi_code {font-family:monospace;} .csharp.geshi_code .imp {font-weight: bold; color: red;} .csharp.geshi_code .kw1 {color: #0600FF;} .csharp.geshi_code .kw2 {color: #FF8000; font-weight: bold;} .csharp.geshi_code .kw3 {color: #008000;} .csharp.geshi_code .kw4 {color: #FF0000;} .csharp.geshi_code .kw5 {color: #000000;} .csharp.geshi_code .co1 {color: #008080; font-style: italic;} .csharp.geshi_code .co2 {color: #008080;} .csharp.geshi_code .co3 {color: #008080;} .csharp.geshi_code .coMULTI {color: #008080; font-style: italic;} .csharp.geshi_code .es0 {color: #008080; font-weight: bold;} .csharp.geshi_code .es_h {color: #008080; font-weight: bold;} .csharp.geshi_code .br0 {color: #000000;} .csharp.geshi_code .sy0 {color: #008000;} .csharp.geshi_code .st0 {color: #666666;} .csharp.geshi_code .st_h {color: #666666;} .csharp.geshi_code .nu0 {color: #FF0000;} .csharp.geshi_code .me1 {color: #0000FF;} .csharp.geshi_code .me2 {color: #0000FF;} .csharp.geshi_code span.xtra { display:block; }
namespace ConsoleApplication4
{
class Structure
{
public struct S0001
{
uint keyLen;
byte[] Key;
byte AuthType;
int ServerVersion;
byte Bonus;
}
}
}
Потом обращаюсь к класу.
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .csharp.geshi_code {font-family:monospace;} .csharp.geshi_code .imp {font-weight: bold; color: red;} .csharp.geshi_code .kw1 {color: #0600FF;} .csharp.geshi_code .kw2 {color: #FF8000; font-weight: bold;} .csharp.geshi_code .kw3 {color: #008000;} .csharp.geshi_code .kw4 {color: #FF0000;} .csharp.geshi_code .kw5 {color: #000000;} .csharp.geshi_code .co1 {color: #008080; font-style: italic;} .csharp.geshi_code .co2 {color: #008080;} .csharp.geshi_code .co3 {color: #008080;} .csharp.geshi_code .coMULTI {color: #008080; font-style: italic;} .csharp.geshi_code .es0 {color: #008080; font-weight: bold;} .csharp.geshi_code .es_h {color: #008080; font-weight: bold;} .csharp.geshi_code .br0 {color: #000000;} .csharp.geshi_code .sy0 {color: #008000;} .csharp.geshi_code .st0 {color: #666666;} .csharp.geshi_code .st_h {color: #666666;} .csharp.geshi_code .nu0 {color: #FF0000;} .csharp.geshi_code .me1 {color: #0000FF;} .csharp.geshi_code .me2 {color: #0000FF;} .csharp.geshi_code span.xtra { display:block; }
Structure strct = new Structure();
А вот теперь как обратится например к переменной /** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .csharp.geshi_code {font-family:monospace;} .csharp.geshi_code .imp {font-weight: bold; color: red;} .csharp.geshi_code .kw1 {color: #0600FF;} .csharp.geshi_code .kw2 {color: #FF8000; font-weight: bold;} .csharp.geshi_code .kw3 {color: #008000;} .csharp.geshi_code .kw4 {color: #FF0000;} .csharp.geshi_code .kw5 {color: #000000;} .csharp.geshi_code .co1 {color: #008080; font-style: italic;} .csharp.geshi_code .co2 {color: #008080;} .csharp.geshi_code .co3 {color: #008080;} .csharp.geshi_code .coMULTI {color: #008080; font-style: italic;} .csharp.geshi_code .es0 {color: #008080; font-weight: bold;} .csharp.geshi_code .es_h {color: #008080; font-weight: bold;} .csharp.geshi_code .br0 {color: #000000;} .csharp.geshi_code .sy0 {color: #008000;} .csharp.geshi_code .st0 {color: #666666;} .csharp.geshi_code .st_h {color: #666666;} .csharp.geshi_code .nu0 {color: #FF0000;} .csharp.geshi_code .me1 {color: #0000FF;} .csharp.geshi_code .me2 {color: #0000FF;} .csharp.geshi_code span.xtra { display:block; }
keyLen
Буду благодарен за ответы.
1 ответов
744 Просмотра за сутки и ни одного ответа.
А ответ прост.
namespace ConsoleApplication4
{
class Structure
{
public _S0001 S0001;
public struct _S0001
{
uint keyLen;
byte[] Key;
byte AuthType;
int ServerVersion;
byte Bonus;
}
}
}
Обращение:
Structure strct = new Structure();
strct.S0001.keyLen = 12;