- 热门文章:
- · c#中的interface abstract与virtual
- · MapX从数据库读取数据形成新图层(C#)
- · C#对XML操作:建立XML(2)
- · C#对XML操作:建立XML(1)
- · C#调用父类的父类的方法
- · .NET中C#实现C/S架构下的TREEVIEW只需要输入表名,父ID,节点ID,节点名就可以得到树型结构
- · what is new in c sharp 2.0--study from msdn
- · C#设计模式之建造者(Builder)模式示例源代码
- · UBB(c#完整版)
- · c#中结构与类的区别
- · 三层结构
- · Destructors in C#
几个C# PROGRAMS (2)
using System;
using System.Text.RegularExpressions;
namespace Wrox.ProCSharp.RegularExpressionPlayaround
{
class MainEntryPoint
{
static void Main()
{
Find1();
Console.ReadLine();
}
static void Find1()
{
string text = @"XML has made a major impact in almost every aspect of
software development. Designed as an open, extensible, self-describing
language, it has become the standard for data and document delivery on
the web. The panoply of XML-related technologies continues to develop
at breakneck speed, to enable validation, navigation, transformation,
linking, querying, description, and messaging of data.";
string pattern = @"\bn\S*ion\b";
MatchCollection matches = Regex.Matches(text, pattern,
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace |
RegexOptions.ExplicitCapture);
WriteMatches(text, matches);
}
static void Find2()
{
string text = @"XML has made a major impact in almost every aspect of
software development. Designed as an open, extensible, self-describing
language, it has become the standard for data and document delivery on
the web. The panoply of XML-related technologies continues to develop
at breakneck speed, to enable validation, navigation, transformation,
linking, querying, description, and messaging of data.";
string pattern = @"\bn";
MatchCollection matches = Regex.Matches(text, pattern,
RegexOptions.IgnoreCase);
WriteMatches(text, matches);
}
static void WriteMatches(string text, MatchCollection matches)
{
Console.WriteLine("Original text was: \n\n" + text + "\n");
Console.WriteLine("No. of matches: " + matches.Count);
foreach (Match nextMatch in matches)
{
int Index = nextMatch.Index;
string result = nextMatch.ToString();
int charsBefore = (Index < 5) ? Index : 5;
int fromEnd = text.Length - Index - result.Length;
int charsAfter = (fromEnd < 5) ? fromEnd : 5;
int charsToDisplay = charsBefore + charsAfter + result.Length;
Console.WriteLine("Index: {0}, \tString: {1}, \t{2}",
Index, result,
text.Substring(Index - charsBefore, charsToDisplay));
}
}
}
}
using System;
using System.Text;
namespace Wrox.ProCSharp.StringEncoder
{
class MainEntryPoint
{
static void Main(string[] args)
{
string greetingText = "Hello from all the guys at Wrox Press. ";
greetingText += "We do hope you enjoy this book as much as we enjoyed writing it.";
for(int i = (int)@#z@#; i>=(int)@#a@# ; i--)
{
char Old = (char)i;
char New = (char)(i+1);
greetingText = greetingText.Replace(Old, New);
}
for(int i = (int)@#Z@#; i>=(int)@#A@# ; i--)
{
char Old = (char)i;
char New = (char)(i+1);
greetingText = greetingText.Replace(Old, New);
}
Console.WriteLine("Encoded:\n" + greetingText);
StringBuilder greetingBuilder =
new StringBuilder("Hello from all the guys at Wrox Press. ", 150);
greetingBuilder.Append("We do hope you enjoy this book as much as we enjoyed writing it");
for(int i = (int)@#z@#; i>=(int)@#a@# ; i--)
{
char Old = (char)i;
char New = (char)(i+1);
greetingBuilder = greetingBuilder.Replace(Old, New);
}
for(int i = (int)@#Z@#; i>=(int)@#A@# ; i--)
{
char Old = (char)i;
char New = (char)(i+1);
greetingBuilder = greetingBuilder.Replace(Old, New);
}
Console.WriteLine("Encoded:\n" + greetingBuilder.ToString());
}
}
}
- · 链表类具有哈希表的功能
- · C#中委托,事件理解入门
- · Introduce event delegate
- · 替换以|分割的相同字符串
- · IOCP Thread Pooling in C#
- · C# struct class Differences
- · C#冒泡算法!
- · C#写的数据库操作类!
- · 快速开发vs.net+c#程序(-)
- · C#对XML操作:编辑XML文件内容
- · 用C#生成Excel文件的方法和Excel.dll组件生成的方法
- · 用C#实现Web文件的上传
- · C#编写的生成缩略图程序
- · 用一个留言簿说明C#操作XML的完全过程
- · 递归枚举排列、组合的C#源码
- · C#反编译微软MSDN2003的帮助文档,并将反编译结果保存到一个SQLSERVER数据库中
- · 用C#轻松在DOTNET中实现缩略图
- · c#中结构与类的区别
- · DES加密算法在C#下的实现
- · C#对XML操作:建立XML(3)
- · 上传图片画带阴影的水印.(C#)
- · Destructors in C#
- · 特洛伊木马服务器源代码(C#)
- · [C#]I/O完成端口的类定义和测试实例
- · 选择文件夹的对话框控件c#
- · C#实现Web文件的上传
- · 用C#实现生成PDF文档
- · 用C#实现生成PDF文档
- · 一个FTP客户端的C#代码
- · C# struct & class Differences
- · C++编程人员容易犯的10个C#错
- · C#冒泡算法!
- · 如何在C#的WinForm中制作饼状图和柱状图
- · 使用响应文件编译C#源文件
- · 用C#写vs插件中的一些Tip
- · 用C#生成中文汉字验证码的基本原理
- · 用托盘控制windows服务的c#实现
- · ASP.NET的实时天气及24小时天气预报(C#)
