惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
U
Unit 42
D
Docker
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
V
Visual Studio Blog
I
InfoQ
Google DeepMind News
Google DeepMind News
小众软件
小众软件
L
LangChain Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
J
Java Code Geeks
罗磊的独立博客

博客园 - DODONG

在现有PDF文件上添加水印 c#获取硬件信息 一个读写csv文件的C#类 . C#操作Excel文件(读取Excel,写入Excel) . 解决全球化时区问题 利用ReportViewer读取Reporting Service数据 [转]用反射来处理多字段提交 查询数据表中重复的记录 CVS文件导入SQL ComponentArt.Web.UI中AJAX TreeView 抽象工厂(Abstract Factory)模式 简单工厂(Simple Factory)模式 工厂方法(Factory Method)模式 用.NET创建Windows服务 关于SharePoint中查询写法和注意的地方 初识WAP开发时.. C#操作XML XMLHttp客户端操作数据 asp.net网页智能导航SmartNavigation的替代实现方式
关于&运算符和^
DODONG · 2006-05-24 · via 博客园 - DODONG

 一直以来都没有关注过算法,看数的时候运算符那一栏基本略过,今天刚巧碰上用到幂的次方算法, ^ 号原来在C#中居然是“异或”和在VB中区别太大了,这个问题在后来才被一同事发现.


C#写法

string TxtRights ="";
 CurRight
=0;
for(int i=0;i< 5;i++)
   
{
    
if ( ((Convert.ToInt32(Rights) &  (int)Math.Pow(2,i)) ==(int)Math.Pow(2,i); ))
    
{
     CurRight
= (int)Math.Pow(2,i);;
     TxtRights 
= TxtRights+","+ CurRight;
    }

   }

----------------------------------Rights ------
VB写法
TxtRights
=""
For i
=0 To 12
 If (Rights And (
2^i))<>0 Then
 CurRight
=2^i
 TxtRights
=TxtRights&","&CurRight
End If
Next