- 浏览: 401042 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
BitVector is something that provided by the .net Framework, which is provided to aim the development in the memory effecient way.
You can use the BitVector to create some bit flags construct; The BitVector also has the concept of Sectoin, whereas you can group several bit to a bit section, and operate on the bitsection as a whole.
The original code is copied and remodeld from the MSDN discussion, for more detail son the APIs, please see the origial site here: "BitVector Structure"
Use the BitVector to create bit flags
In the following code, it shows how to create the bit flags and the relevante bit mask with the help of BItVector.
public static void DemoBitVector32() { BitVector32 myBV = new BitVector32(); int myBit1 = BitVector32.CreateMask(); // A mask that isolates the bit flag following the one that previous points to in System.Collections.Specialized.BitVector32. int myBit2 = BitVector32.CreateMask(myBit1); // it can accept the previous bit order int myBit3 = BitVector32.CreateMask(myBit2); // it can accept the previous bit order int myBit4 = BitVector32.CreateMask(myBit3); // it can accept the previous bit order int myBit5 = BitVector32.CreateMask(myBit4); // it can accept the previous bit order // set the alternating bit to TRUE: Console.WriteLine("Setting alternating bits to TRUE"); Console.WriteLine(" Initial: {0}", myBV.ToString()); myBV[myBit1] = true; Console.WriteLine("Setting alternating bits to TRUE"); Console.WriteLine(" Initial: {0}", myBV.ToString()); myBV[myBit3] = true; Console.WriteLine("Setting alternating bits to TRUE"); Console.WriteLine(" Initial: {0}", myBV.ToString()); myBV[myBit5] = true; Console.WriteLine("Setting alternating bits to TRUE"); Console.WriteLine(" Initial: {0}", myBV.ToString()); }
Use BitVector to create Bit Sections
The following code uses the BitVector to create bit Sections.
public static void DemoBitVector32_v2() { BitVector32 myBV = new BitVector32(0); BitVector32.Section mySect1 = BitVector32.CreateSection(6); BitVector32.Section mySect2 = BitVector32.CreateSection(3, mySect1); BitVector32.Section mySect3 = BitVector32.CreateSection(1, mySect2); BitVector32.Section mySect4 = BitVector32.CreateSection(15, mySect3); // Displays the values of the sections. Console.WriteLine("Initial values:"); Console.WriteLine("\tmySect1: {0}", myBV[mySect1]); Console.WriteLine("\tmySect2: {0}", myBV[mySect2]); Console.WriteLine("\tmySect3: {0}", myBV[mySect3]); Console.WriteLine("\tmySect4: {0}", myBV[mySect4]); Console.WriteLine("Changing the value of each section\n"); Console.WriteLine("\tInitial: \t{0}", myBV.ToString()); myBV[mySect1] = 5; Console.WriteLine("\tmySect1 = 5:\t{0}", myBV.ToString()); myBV[mySect2] = 3; Console.WriteLine("\tmySect1 = 5:\t{0}", myBV.ToString()); myBV[mySect3] = 1; Console.WriteLine("\tmySect1 = 5:\t{0}", myBV.ToString()); myBV[mySect4] = 9; Console.WriteLine("\tmySect1 = 5:\t{0}", myBV.ToString()); Console.WriteLine("New values:"); Console.WriteLine("\tmySect1: {0}", myBV[mySect1]); Console.WriteLine("\tmySect2: {0}", myBV[mySect2]); Console.WriteLine("\tmySect3: {0}", myBV[mySect3]); Console.WriteLine("\tmySect4: {0}", myBV[mySect4]); }
发表评论
-
wpf - example to enhance ComboBox for AutoComplete
2014-09-19 15:56 1979first let’s see an example ... -
Investigate and troubleshoot possible memory leak issue of .NET application
2014-07-31 10:42 0Hi All, I would like to sh ... -
C# – CoerceValueCallback合并、替换元数据值
2013-08-05 21:59 1929Topic: C# – CoerceValueCallbac ... -
wpf – ListView交替背景色
2013-07-02 20:56 6554Wpf – Alternate background col ... -
C# - 简单介绍TaskScheduler
2013-06-29 17:18 12054标题: C# - 简单介绍TaskSchedulerTit ... -
c# - Get enum from enum attribute
2013-06-27 21:32 1252DescriptionAttribute gives the ... -
C# - PInvoke, gotchas on the RegisterClassEx and the CreateWindowEx
2013-06-24 13:49 2576I get an exception message li ... -
c# - Use PInvoke to create simple win32 Application
2013-06-24 11:59 10953In this post, .net platform h ... -
c# - Linq's Select method as the Map function
2013-06-19 18:47 1294If you comes from a functiona ... -
c# - Tips of Linq expression Any to determine if a collection is Empty
2013-06-19 18:29 942When you are @ the linq expres ... -
myth buster - typeof accepting array of types not acceptable
2013-06-19 17:17 819I have seen from some book whe ... -
windows - trying to create WIN32 application with PInvoke
2013-06-19 14:34 0While it is stupid to do such ... -
WPF - Setting foreground color of Entire window
2013-06-13 16:00 1925You might as well as I would s ... -
WPF - Enhanced TabControl - TabControlEx aka Prerendering TabControl
2013-06-13 13:12 5337As an opening word, let's che ... -
wpf - ControlTemplate and AddLogicChild/RemoveLogicalChild
2013-06-10 15:42 1191Recently I was trying to debug ... -
c# - P/Invoke, DllImport, Marshal Structures and Type conversions
2013-06-05 15:25 1717P/Invoke as in the following q ... -
c# - A study on the NativeWindow - encapsulate window handle and procedure
2013-06-05 14:40 6099NativeWindow gives you a way t ... -
WCF - Notify server when client connects
2013-06-03 18:19 1227It is sometimes very importan ... -
wcf - Debug to enable Server exception in Fault message
2013-06-03 15:47 1098WCF will be able to send back ... -
c# - determine if a type/object is serialzable
2013-05-30 16:35 870In WCF, primitives type are s ...
相关推荐
Head First C# -- Third Edition by Andrew Stellman and Jennifer Greene Copyright © 2013 Andrew Stellman and Jennifer Greene. All rights reserved.
标题"C#-ymodem-update"指的是一个使用C#编程语言开发的YMODEM协议实现,主要功能是用于设备固件的升级,特别是针对bootloader的更新。YMODEM是一种流行的串行通信协议,用于在计算机之间传输文件,尤其是在低带宽和...
《大恒双相机开发-C#-多线程项目开源解析》 在当今信息化时代,高效、稳定的图像处理系统成为许多领域不可或缺的技术支持。本项目"大恒-双相机开发-C#-多线程"正是这样的一个实例,它利用C#语言进行编程,实现了对...
在本实例中,“protobuf实例-C#-聊天服务器”是基于C#语言实现的一个聊天服务项目,利用protobuf进行数据序列化和反序列化,以便于在网络通信中高效地传输聊天消息。 在C#环境下,protobuf提供了编译器工具,可以将...
### C# 12 in a Nutshell:The Definitive Reference #### 1. Introducing C# and .NET ...examples, and practical guidance for intermediate and advanced programmers looking to master C# and .NET.
C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition by Mark J. Price English | 24 Mar. 2017 | ASIN: B01N8UG78Q | 594 Pages | AZW3 | 23.26 MB Modern Cross-Platform Development ...
A_collection_of_snippets_for_C#,_C++_and_VB._snippetica.zip A_collection_of_snippets_for_C#,_C++_and_VB._snippetica.zip A_collection_of_snippets_for_C#,_C++_and_VB._snippetica.zip A_collection_of_...
在本文中,我们将深入探讨如何使用C#和WPF(Windows Presentation Foundation)技术来实现一个具有抽屉效果的SplitView控件,以及如何通过MD(Material Design)主题重绘原生控件,以达到美观的效果。这个源码Demo...
在IT行业中,C#是一种广泛使用的编程语言,尤其在开发Web应用程序时,它与ASP.NET框架结合,可以创建高效、动态的网站。本教程将深入探讨如何使用C#和ASP.NET构建一个简易的聊天室网页。 首先,让我们理解标题"**C#...
C#编程 数据库操作应用 UseSelect(源码)(源码)C#编程 数据库操作应用 UseSelect(源码)(源码)C#编程 数据库操作应用 UseSelect(源码)(源码)C#编程 数据库操作应用 UseSelect(源码)(源码)C#编程 数据库操作应用 Use...
【标题】"C#版USB-HID范例" 涉及的是在C#编程环境中与USB设备进行Human Interface Device (HID)通信的技术。USB-HID类库允许开发者直接与各种类型的输入设备(如键盘、鼠标、游戏控制器等)进行交互,而无需关心具体...
Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR). This book teaches both core C# language concepts and how to wisely employ C# ...
"C#-升级版文本编辑器"项目显然旨在创建一个增强版的文本编辑器,可能包含了更多特性、优化和自定义选项,以满足更广泛的用户需求。接下来,我们将深入探讨这个项目可能涉及到的C#编程知识和技术点。 1. **Windows ...
以上是对"最新3.3支付宝即时到账交易接口demo源码c#-gbk源码"所涉及的关键知识点的详细解析,通过这个源码,开发者可以学习如何在C#环境下实现与支付宝接口的集成,完成线上支付功能。在实际开发过程中,还需要结合...
#学习的101个经典例子,例子个个经典,涵盖C#的方方面面,带有说详尽的注释 Advanced - Multithreading - How-To Async Calls Advanced - Remoting - How-To TCP Remoting Advanced - Serialization - How-To ...
With Microsoft speeding up its release cadence while offering more significant improvement with each update, it has never been more important to get a handle on new tools and features quickly....
在C# WinForm开发中,数据展示和处理是常见的任务,而`dataGridView`控件是常用的界面元素,用于显示和编辑表格数据。本教程将详细讲解如何高效地将`dataGridView`中的数据批量导出到Excel文件,特别是针对大量数据...