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

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - 小牛哥

招聘.NET软件工程师 2人 招聘.NET软件工程师 2人 招聘.NET高级程序员[深圳] Windows 2003不能用 '..' 表示父目录解决方法 使用JS创建虚拟目录,并引导进入浏览 判断一个字符是否为汉字 Migration from J2EE to .NET 无法打开 Web 项目“DottextWeb”问题的解决 如何解决一个小问题:当前不会命中断点 Lucene.Net的问题我找到了,郁闷 插入表情图标的功能 事务死锁的问题如何解决? 创建虚拟目录和移除虚拟目录 - 小牛哥 - 博客园 Unclean shutdown of previous Apache run? - 小牛哥 VB.NET实现Singleton模式 启动一个进层阻止当前线程 使用DataReader填充DataTable 获得一个随机数 将Html代码转换为Text
Asc和Chr
小牛哥 · 2004-09-25 · via 博客园 - 小牛哥

C#

        public static int Asc(string character)
        
{
            
if (character.Length == 1)
            
{
                System.Text.ASCIIEncoding asciiEncoding 
= new System.Text.ASCIIEncoding();
                
int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0];
                
return (intAsciiCode);
            }

            
else
            
{
                
throw new Exception("Character is not valid.");
            }


        }


        
public static string Chr(int asciiCode)
        
{
            
if (asciiCode >= 0 && asciiCode <= 255)
            
{
                System.Text.ASCIIEncoding asciiEncoding 
= new System.Text.ASCIIEncoding();
                
byte[] byteArray = new byte[]{(byte)asciiCode};
                
string strCharacter = asciiEncoding.GetString(byteArray);
                
return (strCharacter);
            }

            
else
            
{
                
throw new Exception("ASCII Code is not valid.");
            }

        }

VB.NET

    Public Shared Function Asc(ByVal sCharacter As StringAs Integer
        
If sCharacter.Length = 1 Then
            
Dim oASCIIEncoding As New System.Text.ASCIIEncoding
            
Dim iAsciiCode As Integer = CInt(oASCIIEncoding.GetBytes(sCharacter)(0))
            
Return iAsciiCode
        
Else
            
Throw New Exception("Character is not valid.")
        
End If
    
End Function


    
Public Shared Function Chr(ByVal iAsciiCode As IntegerAs String
        
If iAsciiCode >= 0 And iAsciiCode <= 255 Then
            
Dim oASCIIEncoding As New System.Text.ASCIIEncoding
            
Dim oByteArray() As Byte = {CByte(iAsciiCode)}
            
Dim sCharacter As String = oASCIIEncoding.GetString(oByteArray)
            
Return sCharacter
        
Else
            
Throw New Exception("ASCII Code is not valid.")
        
End If
    
End Function

可以完全替代Microsoft.VisualBasic.Strings.Asc和Microsoft.VisualBasic.Strings.Chr

posted on 2004-09-25 13:10  小牛哥  阅读(2703)  评论(7)    收藏  举报