日期:2014-05-19  浏览次数:20784 次

C和C#类型问题
int   WINAPI   SW_StartFileRecord(int   nIndex,   char   *   FileName   ,   DWORD   FileLength   );

把C写的方法转换成C#的方法怎么改
int     SW_StartFileRecord(int   nIndex,string   FileName,         )
第三个参数怎么写呀第三个参数是用来指定(.wav)的长度的请大家帮帮忙

------解决方案--------------------
DWORD 4字节,相当于uint.
------解决方案--------------------
1.了解什么是 "变量 "

2.学习C#的简单类型

3.对C#表达式有个初步的了解

4.了解什么是String类型

5.学习如何使用数组

"变量 "仅仅是数据的存储位置。你可以把数据存放到其中,或者从中取出来作为C#表达式的一部分。变量中所存放的数据的含义是通过类型来控制的。

C#是个强类型(???)的语言。这样,一切对变量的操作都是针对该变量的类型而进行的。为了保证变量中所存放数据的合法性和一致性,对不同类型的变量进行操作有相应的规则。

C#语言的简单类型包含布尔类型和三种数值类型:整型,浮点型和小数。

1.清单1-1 显示布尔值:Boolean.cs

using System;
class Booleans {
public static void Main() {
bool content = true;
bool noContent = false;
Console.WriteLine( "It is {0} that C# Station provides C# programming language content. ", content);
Console.WriteLine( "The statement above is not {0}. ", noContent);
}
}

说明

1.在清单1-1中,布尔值作为句子的一部分输出到控制台中。 "bool "类型的取值要么为真,要么为假。程序运行结果如下:

> It is True that C# Station provides C# programming language content.
> The statement above is not False.

2.下列表格显示了各种整数类型,所占字节大小和所能表示的数的范围。

类型 位 范围
sbyte 8 -128 to 127
byte 8 0 to 255
short 16 -32768 to 32767
ushort 16 0 to 65535
int 32 -2147483648 to 2147483647
uint 32 0 to 4294967295
long 64 -9223372036854775808 to 9223372036854775807
ulong 64 0 to 18446744073709551615
char 16 0 to 65535

在对整数进行计算时,除了字符类型之外,上述这些类型都是适合的。字符类型代表一个Unicode字符。正如在上表中可以看到的,你可以从中选择适合你需要的类型。

3.下列表格显示了单精度类型,双精度类型和小数类型的数据,它们所占的字节,精度和所能表示的数的范围。

类型 位 精度 范围
float 32 7 digits 1.5 x 10-45 to 3.4 x 1038
double 64 15-16 digits 5.0 x 10-324 to 1.7 x 10308
decimal 128 28-29 decimal places 1.0 x 10-28 to 7.9 x 1028

当你需要进行涉及到分数的操作时,就需要用到实型,然而,对于金融财经方面的数据的计算,小数类型也许是你最好的选择。

4.表达式计算之后可以得出结果。这些表达式把变量和运算符一同放到语句中。下表列出了C#允许的运算符,优先级和结合性。

分类 运算符 结合性
初级 (x) x.y f(x) a[x] x++ x-- new typeof sizeof checked unchecked 左
单目 + - ! ~ ++x --x (T)x 左
乘法等 * / % 左
加法等 + - 左
移位 < < > > 左
关系 < > <= > = is 左
相等 == != 右
逻辑与 & 左
逻辑异或 ^ 左
逻辑或 | 左
条件与 && 左
条件或 || 左
条件 ?: 右
赋值等 = *= /= %= += -= < <= > > = &= ^= |= 右

左结合意味着运算符是从左到右进行运算的。右结合意味着所有的运算是从右到左进行的,如赋值运算符,要等到其右边的计算出来之后,才把结果放到左边的变量中。

2.清单 1-2. 单目运算符: Unary.cs

using System;
class Unary {
public static void Main() {
int unary = 0;
int preIncrement;
int preDecrement;
int postIncrement;
int postDecrement;
int positive;
int negative;
sbyte bitNot;
bool logNot;
preIncrement = ++unary;
Console.WriteLine( "Pre-Increment: {0} ", preIncrement);
preDecrement = --unary;
Console.WriteLine( "Pre-Decrement: {0} ", preDecrement);
postDecrement = unary--;
Console.WriteLine( "Post-Decrement: {0} ", postDecrement);
postIncrement = unary++;
Console.WriteLine( "Post-Increment: {0} ", postIncrement);
Console.WriteLine( "Final Value of Unary: {0} ", unary);
positive = -postIncrement;
Console.WriteLine( "Positive: {0} ", positive);
negative = +postIncrement;
Console.WriteLine( "Negative: {0} ", negative);
bitNot = 0;
bitNot = (sbyte)(~bitNot);