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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - 小牛哥

招聘.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)    收藏  举报