本文整理汇总了C#中Byte类的典型用法代码示例。如果您正苦于以下问题:C# Byte类的具体用法?C# Byte怎么用?C# Byte使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Byte类属于命名空间,在下文中一共展示了Byte类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReadWriteAsyncParams
public ReadWriteAsyncParams(Byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
this.Buffer = buffer;
this.Offset = offset;
this.Count = count;
this.CancellationHelper = cancellationToken.CanBeCanceled ? new IOCancellationHelper(cancellationToken) : null;
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:7,代码来源:PipeStream.Windows.cs
示例2: WrapUnderlyingBytes
public void WrapUnderlyingBytes()
{
var rawBytes = new Byte[0];
var bytes = new Binary(rawBytes);
Assert.Same(rawBytes, (Byte[])bytes);
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryTests.cs
示例3: CopiesResult
public void CopiesResult()
{
// Note that a preable is not expected on the generated stream.
string text = "Hello world";
Byte[] textInBytes = Encoding.UTF8.GetBytes(text);
string outputText;
Byte[] buffer = new Byte[1024];
using (MemoryStream stream = new MemoryStream(buffer))
using (StringWriter writer = new StringWriter())
using (StreamWriter outputWriter = new StreamWriter(stream))
{
writer.Write(text);
writer.CopyTo(outputWriter);
outputText = writer.ToString();
}
Assert.Equal(text, outputText, StringComparer.Ordinal);
for (int i = 0; i < textInBytes.Length; i++)
{
Assert.Equal(textInBytes[i], buffer[i]);
}
}
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:26,代码来源:StringWriterExtensionsTest.cs
示例4: DecompressArray
public static Byte[] DecompressArray(Byte[] inBuf)
{
Logger.Enter();
MemoryStream memory = new MemoryStream();
try
{
using (GZipStream stream = new GZipStream(new MemoryStream(inBuf), CompressionMode.Decompress))
{
const int size = 4096;
byte[] buffer = new byte[size];
int count = 0;
do
{
count = stream.Read(buffer, 0, size);
if (count > 0)
{
memory.Write(buffer, 0, count);
}
}
while (count > 0);
}
}
catch(Exception ex)
{
Logger.Error(String.Format("Decompress error.Internal msg: {0}", ex.Message));
}
Logger.Leave();
return memory.ToArray();
}
开发者ID:AndrianDTR,项目名称:Atlantic,代码行数:32,代码来源:Packer.cs
示例5: Decrement
public void Decrement()
{
// Reduce the size of the byte by 1 (note that this does not check for overflows!)
Byte b = new Byte(1);
b.TwosComplement();
RippleAdd(b);
}
开发者ID:eoinrogers,项目名称:GamesEngines1Assignment,代码行数:7,代码来源:Byte.cs
示例6: OnlyUsesBufferUpToSize
public void OnlyUsesBufferUpToSize(int count)
{
string text = new string('a', count);
Byte[] textInBytes = Encoding.UTF8.GetBytes(text);
Mock<StreamWriter> mock;
Byte[] buffer = new Byte[textInBytes.Length + 100];
using (MemoryStream stream = new MemoryStream(buffer))
{
StringWriter writer = new StringWriter();
mock = new Mock<StreamWriter>(MockBehavior.Strict, stream) { CallBase = true };
mock.Setup(sw => sw.Write(It.IsAny<char[]>(),
It.IsAny<int>(),
It.Is<int>(c => c == StringWriterExtensions.BufferSize ||
c == textInBytes.Length % StringWriterExtensions.BufferSize)))
.Verifiable();
StreamWriter outputWriter = mock.Object;
writer.Write(text);
writer.CopyTo(outputWriter);
mock.Verify();
}
}
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:27,代码来源:StringWriterExtensionsTest.cs
示例7: DecompressString
public static string DecompressString(Byte[] value)
{
if (value.Length > 0)
return Encoding.UTF8.GetString(CLZF.Decompress(value));
else
return "";
}
开发者ID:Kayrohinc,项目名称:Countries,代码行数:7,代码来源:StringCompressor.cs
示例8: PosTest2
public void PosTest2()
{
Byte[] bytes = new Byte[] { };
UTF7Encoding UTF7 = new UTF7Encoding();
int charCount = UTF7.GetCharCount(bytes, 0, 0);
Assert.Equal(0, charCount);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:UTF7EncodingGetCharCount.cs
示例9: CanCompareToBoxedRawBytes
public void CanCompareToBoxedRawBytes()
{
var lhs = new Binary(new Byte[] { 1, 2, 3 });
var rhs = new Byte[] { 1, 2, 3 };
Assert.Equal(0, lhs.CompareTo((Object)rhs));
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryTests.cs
示例10: ToggleBit
public void ToggleBit(byte register, int bit_position)
{
Byte b = new Byte(Read(register)); // Read control register
b.ToggleBit(bit_position); // Modify oscillator bit
// Write new byte value
Write(register, b.ToByte());
}
开发者ID:binary10,项目名称:Netduino,代码行数:8,代码来源:DS3232Connection.cs
示例11: ModifyBaseStream
public async Task ModifyBaseStream()
{
var ms = await LocalMemoryStream.readAppFileAsync(gzTestFile("GZTestDocument.txt.gz"));
var zip = new GZipStream(ms, CompressionMode.Decompress);
int size = 1024;
Byte[] bytes = new Byte[size];
zip.BaseStream.Read(bytes, 0, size); // This will throw if the underlying stream is not writeable as expected
}
开发者ID:Cythical,项目名称:corefx,代码行数:9,代码来源:GZipStreamTests.cs
示例12: PosTest3
public void PosTest3()
{
UnicodeEncoding uE = new UnicodeEncoding(false, true);
Byte[] expectedValue = new Byte[] { 0xff, 0xfe };
Byte[] actualValue;
actualValue = uE.GetPreamble();
Assert.Equal(expectedValue, actualValue);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetPreamble.cs
示例13: PosTest1
public void PosTest1()
{
Byte[] bytes = new Byte[] {
85, 84, 70, 56, 32, 69, 110,
99, 111, 100, 105, 110, 103, 32,
69, 120, 97, 109, 112, 108, 101};
UTF7Encoding utf7 = new UTF7Encoding();
string str = utf7.GetString(bytes, 0, bytes.Length);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:UTF7EncodingGetString.cs
示例14: GAPScanResponseEventArgs
public GAPScanResponseEventArgs(Byte rssi, Byte packet_type, Byte[] bd_addr, Byte address_type, Byte bond, Byte[] data)
{
this.rssi = rssi;
this.packet_type = packet_type;
this.bd_addr = bd_addr;
this.address_type = address_type;
this.bond = bond;
this.data = data;
}
开发者ID:shariat,项目名称:bglib,代码行数:9,代码来源:BGLib.cs
示例15: PosTest3
public void PosTest3()
{
Char[] chars = GetCharArray(10);
Byte[] bytes = new Byte[20];
UnicodeEncoding uEncoding = new UnicodeEncoding();
int actualValue;
actualValue = uEncoding.GetBytes(chars, 0, 0, bytes, 20);
Assert.Equal(0, actualValue);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetBytes1.cs
示例16: PosTest1
public void PosTest1()
{
Byte[] bytes;
String chars = "UTF7 Encoding Example";
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = chars.Length;
bytes = new Byte[byteCount];
int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UTF7EncodingGetBytes2.cs
示例17: PosTest3
public void PosTest3()
{
String chars = GetString(10);
Byte[] bytes = new Byte[30];
UnicodeEncoding uEncoding = new UnicodeEncoding();
int actualValue;
actualValue = uEncoding.GetBytes(chars, 0, 0, bytes, 30);
Assert.Equal(0, actualValue);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UnicodeEncodingGetBytes2.cs
示例18: SystemBootEventArgs
public SystemBootEventArgs(UInt16 major, UInt16 minor, UInt16 patch, UInt16 build, UInt16 ll_version, Byte protocol_version, Byte hw)
{
this.major = major;
this.minor = minor;
this.patch = patch;
this.build = build;
this.ll_version = ll_version;
this.protocol_version = protocol_version;
this.hw = hw;
}
开发者ID:shariat,项目名称:bglib,代码行数:10,代码来源:BGLib.cs
示例19: PosTest2
public void PosTest2()
{
Byte[] bytes;
String chars = "";
UTF7Encoding UTF7 = new UTF7Encoding();
int byteCount = chars.Length;
bytes = new Byte[byteCount];
int bytesEncodedCount = UTF7.GetBytes(chars, 0, byteCount, bytes, 0);
Assert.Equal(0, bytesEncodedCount);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UTF7EncodingGetBytes2.cs
示例20: PosTest2
public void PosTest2()
{
Char[] chars;
Byte[] bytes = new Byte[] { };
UTF7Encoding UTF7 = new UTF7Encoding();
int charCount = UTF7.GetCharCount(bytes, 0, 0);
chars = new Char[] { };
int charsDecodedCount = UTF7.GetChars(bytes, 0, 0, chars, 0);
Assert.Equal(0, charsDecodedCount);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UTF7EncodingGetChars.cs
注:本文中的Byte类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论