读书人

枚举做参数的有关问题 多谢

发布时间: 2012-01-30 21:15:58 作者: rapoo

枚举做参数的问题 谢谢啊
namespace System.IO
{
// Summary:
// Provides the fields that represent reference points in streams for seeking.
[Serializable]
[ComVisible(true)]
public enum SeekOrigin
{
// Summary:
// Specifies the beginning of a stream.
Begin = 0,
//
// Summary:
// Specifies the current position within a stream.
Current = 1,
//
// Summary:
// Specifies the end of a stream.
End = 2,
}

上面这个是系统的定好的一个枚举


我想在下面这个函数里 用这个枚举,该如何声明?
byte[] data = dc.GetPartialTagData(tagId, seek , offset, length);
seek 这个应该是枚举类型的

还有个问题就是,SEEK 这个枚举变量,如何改变其值,

如原来是 begin=0;end= 2

可以不可以在当参数向下传递时,对begin和end重新赋予新值呢?




[解决办法]
SeekOrigin seek就ok
枚举 实际上 是一种 常量值
不可以重新赋值
[解决办法]
TO:同时在按钮的代码 开始处声明 seekorigin seek

用int类型就行了..
[解决办法]
同意楼上的,在声明的时候指出是int型的。

public enum SeekOrigin : int
{
// Summary:
// Specifies the beginning of a stream.
Begin = 0,
//
// Summary:
// Specifies the current position within a stream.
Current = 1,
//
// Summary:
// Specifies the end of a stream.
End = 2,
}
[解决办法]
seekorigin seek=null;也是一样的撒。不用非要声明为int
[解决办法]
TO:但我发现这个参数 没有用啊

因为到DSPI层 没办法得到这个值

列出来也挺麻烦,大家没这个开发环境,越描越乱

不用列啊..

要用的话,就直接转就行了..

public byte[] GetPartialTagData(int tagId, int seek , int offset, int length)
{
//在要用的地方,直接强制转换一下即可,即:(SeekOrigin)seek
}

读书人网 >C#

热点推荐