readFile 把数据读到缓冲区 怎样取换行符

wyqiang 2006-06-17 01:12:23
实现类似于grep的搜索程序。在指定目录的所有文件中搜寻指定的字符串。


假设:这个目录下的所有文件均为文本文件;并且目录深度不超过32.

要求:

1)输出匹配的行数及所在文件名。

2)匹配时,大小写不敏感。

3) 指定目录和指定字符串均从main或WinMain的参数中读入。

4) 不能限定将要搜索的文件的大小。

5) 使用Win32 API中的文件I/O函数,例如: CreateFile, ReadFile, WriteFile等。

6) 也可使用NSPR中的文件I/O函数,例如: PR_Open, PR_Read等。

7) 不能使用C或C++的I/O方法。
/////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define MAC_FILENAMELENOPATH 50

int length(char T[])
{
int i = 0;
while(T[i] != '\0')
i++;
return i;
}

void readOneFile(char strFile[])
{
unsigned long i = 0;
int line = 1;
int j = 0;
BOOL bResult;
HANDLE handle;
char inBuffer[1024];
char upBuffer[1024];
char lowBuffer[1024];
ZeroMemory(inBuffer,1024);
DWORD nBytesRead;
handle = CreateFile("c:\\hello\\hello.txt",GENERIC_READ|GENERIC_WRITE,
0,NULL,OPEN_ALWAYS,FILE_FLAG_RANDOM_ACCESS,NULL);
if(INVALID_HANDLE_VALUE == handle)
{
printf("error!");
CloseHandle(handle);
return;
}

bResult = ReadFile(handle, &inBuffer,1024, &nBytesRead, NULL);
while(bResult)
{
if ( nBytesRead == 0)
{
CloseHandle(handle);
return;
}
/*
strcpy(upBuffer, _strupr(inBuffer));
while(i != nBytesRead)
{
while(upBuffer[i] != '0x0A')
{
while(upBuffer[i] == strMatch[j])
{
i++;
j++;
if(j == length(strMatch))
printf("%d,%s\r\n",line,strMatch);
}
j=0;
i++;
}
line++;
}

*/
strcpy(upBuffer, _strupr(inBuffer));
printf("%s",upBuffer);
// strcpy(lowBuffer, _strlwr(inBuffer));
ZeroMemory(inBuffer,1024);
bResult = ReadFile(handle, &inBuffer,1024, &nBytesRead, NULL);
i=0;
}

CloseHandle(handle);
return;
}


void FindFileInDir(char *rootDir, char *strRet)
{
char fname[MAC_FILENAMELENOPATH];
ZeroMemory(fname, MAC_FILENAMELENOPATH);
WIN32_FIND_DATA fd;
ZeroMemory(&fd, sizeof(WIN32_FIND_DATA));

HANDLE h_Search;
char filePathName[256];
char tempPath[256];
ZeroMemory(filePathName, 256);
ZeroMemory(tempPath, 256);

strcpy(filePathName, rootDir);
BOOL bSearchFindShed = FALSE;

if(filePathName)
{
strcat(filePathName, "\\\\");
}
strcat(filePathName, "*.*");

h_Search = FindFirstFile(filePathName, &fd);


if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName, "..")!=0 && strcmp(fd.cFileName, ".")!=0)
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\\\");
strcat(tempPath, fd.cFileName);
printf("%s\r\n", fd.cFileName);
FindFileInDir(tempPath, strRet);

}
else if( fd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE )
{
char HouZhui[5];
strncpy(HouZhui, fd.cFileName+strlen(fd.cFileName)-4, 4);
HouZhui[4] = '\0';
char *StrTemp = _strupr(HouZhui);
if( strcmp(StrTemp, ".TXT")==0 )
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\\\");
strcat(tempPath, fd.cFileName);
// printf("%s\r\n", tempPath);
readOneFile(tempPath);
strcpy(fname, fd.cFileName);
strcat(strRet+strRet[strlen(strRet)], fname);
}
}

while(!bSearchFindShed)
{
if(FindNextFile(h_Search, &fd))
{
if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName, "..")!=0 && strcmp(fd.cFileName, ".")!=0)
{
strcpy(tempPath,rootDir);
strcat(tempPath, "\\\\");
strcat(tempPath,fd.cFileName);
FindFileInDir(tempPath,strRet);
}
else if(fd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE)
{
char HouZhui[5];
strncpy(HouZhui, fd.cFileName+strlen(fd.cFileName)-4, 4);
HouZhui[4] = '\0';
char *StrTemp = strupr(HouZhui);
if( strcmp(StrTemp, ".TXT")==0 )
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\\\");
strcat(tempPath, fd.cFileName);
//printf("%s\r\n", tempPath);
readOneFile(tempPath);
strcpy(fname, fd.cFileName);
strcat(strRet+strRet[strlen(strRet)], fname);
}
}
}
else
{
bSearchFindShed = TRUE;
}
}

FindClose(h_Search);
}

int main(int argc,char *argv[])
{

char *strPath = "E:\\\\h";
char FilePath[1024];

ZeroMemory(FilePath, 1024);
FindFileInDir(strPath, FilePath);

// readOneFile();
return 0;
}
...全文
657 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
healer_kx 2006-06-19
  • 打赏
  • 举报
回复
一个字符一个字符的读, 读 \n就是一行了,如果后面存在\r,忽略它即可。
wyqiang 2006-06-18
  • 打赏
  • 举报
回复
/*
6.文件操作(*)

实现类似于 的搜索程序。在指定目录的所有文件中搜寻指定的字符串。


假设:这个目录下的所有文件均为文本文件;并且目录深度不超过32.

要求:

1)输出匹配的行数及所在文件名。

2)匹配时,大小写不敏感。

3) 指定目录和指定字符串均从main或WinMain的参数中读入。

4) 不能限定将要搜索的文件的大小。

5) 使用Win32 API中的文件I/O函数,例如: CreateFile, ReadFile, WriteFile等。

6) 也可使用NSPR中的文件I/O函数,例如: PR_Open, PR_Read等。

7) 不能使用C或C++的I/O方法。

*/
/////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int length(char T[])
{
int i = 0;
while(T[i] != '\0')
i++;
return i;
}

void readOneFile(char *strFile,char *strMatch)
{
unsigned long i = 0;
int line = 1;
int j = 0;
BOOL bResult;
HANDLE handle;
char inBuffer[1024];
char upBuffer[1024];
char upMatch[20];
strcpy(upMatch, strupr(strMatch));
ZeroMemory(inBuffer,1024);
DWORD nBytesRead=0;
handle = CreateFile(strFile,GENERIC_READ,
0,NULL,OPEN_ALWAYS,FILE_FLAG_RANDOM_ACCESS,NULL);
if(INVALID_HANDLE_VALUE == handle)
{
printf("error!");
CloseHandle(handle);
return;
}

bResult = ReadFile(handle, &inBuffer,1024, &nBytesRead, NULL);
while(bResult)
{
if ( nBytesRead == 0)
{
CloseHandle(handle);
return;
}

strcpy(upBuffer, strupr(inBuffer));

while(i <= nBytesRead)
{
while(upBuffer[i] != 0x0d)
{
while(upBuffer[i] == upMatch[j])
{
i++;
j++;
if(j == length(upMatch))
printf("the line is:%d the file name is: %s\r\n",line,strFile);
}
j=0;
i++;

if(i >= nBytesRead)
break;
}
i++;
if(upBuffer[i] == 0x0a)
{
line++;
i++;
}
}
ZeroMemory(inBuffer,1024);
nBytesRead=0;
i=0;
bResult = ReadFile(handle, &inBuffer,1024, &nBytesRead, NULL);
}

CloseHandle(handle);
return;
}


void FindFileInDir( const char *rootDir, char *strRet, char *strMatch)
{
char fname[256];
ZeroMemory(fname, 256);
WIN32_FIND_DATA fd;
ZeroMemory(&fd, sizeof(WIN32_FIND_DATA));

HANDLE h_Search;
char filePathName[256];
char tempPath[256];
char szTempRootDir[256];
ZeroMemory(filePathName, 256);
ZeroMemory(tempPath, 256);

strcpy(filePathName, rootDir);
strcpy(szTempRootDir, rootDir);
BOOL bSearchFindShed = FALSE;

if(filePathName)
{
strcat(filePathName, "\\");
}
strcat(filePathName, "*.*");

h_Search = FindFirstFile(filePathName, &fd);


if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName, "..")!=0 && strcmp(fd.cFileName, ".")!=0)
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\");
strcat(tempPath, fd.cFileName);
printf("%s\r\n", fd.cFileName);
FindFileInDir(tempPath, strRet, strMatch);

}
else if( fd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE )
{
char HouZhui[5];
strncpy(HouZhui, fd.cFileName+strlen(fd.cFileName)-4, 4);
HouZhui[4] = '\0';
char *StrTemp = _strupr(HouZhui);
//只读 *.TXT文件
if( strcmp(StrTemp, ".TXT")==0 )
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\");
strcat(tempPath, fd.cFileName);
// printf("%s\r\n", tempPath);
readOneFile(tempPath,strMatch);
strcpy(fname, fd.cFileName);
strcat(strRet+strlen(strRet), "\\");
strcat(strRet+strlen(strRet), fname);
}
}

while(!bSearchFindShed)
{
if(FindNextFile(h_Search, &fd))
{
if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName, "..")!=0 && strcmp(fd.cFileName, ".")!=0)
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\");
strcat(tempPath, fd.cFileName);
FindFileInDir(tempPath, strRet, strMatch);
}
else if(fd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE)
{
char HouZhui[5];
strncpy(HouZhui, fd.cFileName+strlen(fd.cFileName)-4, 4);
HouZhui[4] = '\0';
char *StrTemp = strupr(HouZhui);
if( strcmp(StrTemp, ".TXT")==0 )
{
ZeroMemory(tempPath, 256);
strcpy(tempPath, rootDir);
strcat(tempPath, "\\");
strcat(tempPath, fd.cFileName);
// printf("%s\r\n", tempPath);
readOneFile(tempPath,strMatch);
strcpy(fname, fd.cFileName);
strcat(strRet+strlen(strRet), "\\");
strcat(strRet+strlen(strRet), fname);
}
}
}
else
{
bSearchFindShed = TRUE;
}
}

FindClose(h_Search);
}

int main(int argc,char *argv[])
{
char rootDir[256] = {0};
char strRet[1024] = {0};
char strMatch[20] = {0};
printf("please input the string!\r\n");
scanf("%s",strMatch);

printf("please input the Directory!\r\n");
scanf("%s", rootDir);

FindFileInDir(rootDir, strRet, strMatch);
return 0;
}
/*
please input the string!
MAIN
please input the Directory!
C:\HELLO
the line is:2 the file name is: C:\HELLO\sort.txt
the line is:4 the file name is: C:\HELLO\sort.txt
the line is:5 the file name is: C:\HELLO\sort.txt
the line is:2 the file name is: C:\HELLO\pp.txt
the line is:5 the file name is: C:\HELLO\?? ???? (2).txt
the line is:41 the file name is: C:\HELLO\?? ???? (2).txt
the line is:139 the file name is: C:\HELLO\hello.txt
the line is:2 the file name is: C:\HELLO\?????\add.txt
the line is:2 the file name is: C:\HELLO\?????\pp.txt
the line is:5 the file name is: C:\HELLO\?????\?? ???? (2).txt
the line is:41 the file name is: C:\HELLO\?????\?? ???? (2).txt
Press any key to continue
*/
力为 2006-06-17
  • 打赏
  • 举报
回复
这么长!

问题在哪一行?
wyqiang 2006-06-17
  • 打赏
  • 举报
回复
/////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int length(char T[])
{
int i = 0;
while(T[i] != '\0')
i++;
return i;
}

void readOneFile(char *strFile,char *strMatch)
{
unsigned long i = 0;
int line = 1;
int j = 0;
BOOL bResult;
HANDLE handle;
char inBuffer[1024];
char upBuffer[1024];
char upMatch[20];
strcpy(upMatch, strupr(strMatch));
ZeroMemory(inBuffer,1024);
DWORD nBytesRead=0;
handle = CreateFile(strFile,GENERIC_READ|GENERIC_WRITE,
0,NULL,OPEN_ALWAYS,FILE_FLAG_RANDOM_ACCESS,NULL);
if(INVALID_HANDLE_VALUE == handle)
{
printf("error!");
CloseHandle(handle);
return;
}

bResult = ReadFile(handle, &inBuffer,1024, &nBytesRead, NULL);
while(bResult)
{
if ( nBytesRead == 0)
{
CloseHandle(handle);
return;
}

strcpy(upBuffer, strupr(inBuffer));

while(i <= nBytesRead)
{
while(upBuffer[i] != 0x0d)
{
while(upBuffer[i] == upMatch[j])
{
i++;
j++;
if(j == length(upMatch))
printf("%d,%s\r\n",line,upMatch);
}
j=0;
i++;

if(i >= nBytesRead)
break;
}
i++;
if(upBuffer[i] == 0x0a)
{
line++;
i++;
}
}
ZeroMemory(upBuffer,1024);
printf("%s",upBuffer);
//×?ò?D?????μ??ˉ×÷
ZeroMemory(inBuffer,1024);
nBytesRead=0;
i=0;
bResult = ReadFile(handle, &inBuffer,1024, &nBytesRead, NULL);
}

CloseHandle(handle);
return;
}


void FindFileInDir(const char *rootDir, char *strRet,char *strMatch)
{
char fname[50];
ZeroMemory(fname, 50);
WIN32_FIND_DATA fd;
ZeroMemory(&fd, sizeof(WIN32_FIND_DATA));

HANDLE h_Search;
char filePathName[256];
char tempPath[256];
ZeroMemory(filePathName, 256);
ZeroMemory(tempPath, 256);

strcpy(filePathName, rootDir);
BOOL bSearchFindShed = FALSE;

if(filePathName)
{
strcat(filePathName, "\\\\");
}
strcat(filePathName, "*.*");

h_Search = FindFirstFile(filePathName, &fd);


if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName, "..")!=0 && strcmp(fd.cFileName, ".")!=0)
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\");
strcat(tempPath, fd.cFileName);
printf("%s\r\n", fd.cFileName);
FindFileInDir(tempPath, strRet,strMatch);

}
else if( fd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE )
{
char HouZhui[5];
strncpy(HouZhui, fd.cFileName+strlen(fd.cFileName)-4, 4);
HouZhui[4] = '\0';
char *StrTemp = _strupr(HouZhui);
if( strcmp(StrTemp, ".TXT")==0 )
{
strcpy(tempPath, rootDir);
strcat(tempPath, "\\");
strcat(tempPath, fd.cFileName);
printf("%s\r\n", tempPath);
// readOneFile(tempPath,strMatch);
strcpy(fname, fd.cFileName);
strcat(strRet+strRet[strlen(strRet)], fname);
}
}

while(!bSearchFindShed)
{
if(FindNextFile(h_Search, &fd))
{
if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
strcmp(fd.cFileName, "..")!=0 && strcmp(fd.cFileName, ".")!=0)
{

strcpy(tempPath,rootDir);
//strcpy(filePathName,rootDir);
strcat(tempPath, "\\");
strcat(tempPath,fd.cFileName);
FindFileInDir(tempPath,strRet,strMatch);
}
else if(fd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE)
{
char HouZhui[5];
strncpy(HouZhui, fd.cFileName+strlen(fd.cFileName)-4, 4);
HouZhui[4] = '\0';
char *StrTemp = strupr(HouZhui);
if( strcmp(StrTemp, ".TXT")==0 )
{
ZeroMemory(tempPath, 256);
strcpy(tempPath, rootDir);
//strcpy(filePathName,rootDir);
strcat(tempPath, "\\\\");
strcat(tempPath, fd.cFileName);
printf("%s\r\n", tempPath);
// readOneFile(tempPath,strMatch);
strcpy(fname, fd.cFileName);
strcat(strRet+strRet[strlen(strRet)], fname);

}
}
}
else
{
bSearchFindShed = TRUE;
}
}

FindClose(h_Search);
}

int main(int argc,char *argv[])
{
/*
char rootDir[50];// = "E:\\\\h";
char strRet[1024];
char strMatch[20];
printf("please input the string!\r\n");
scanf("%s",strMatch);

printf("please input the Directory!\r\n");
scanf("%s",rootDir);

FindFileInDir(rootDir, strRet,strMatch);
*/
char strMatch[20];
printf("please input the string!\r\n");
scanf("%s",strMatch);

char strFile[20];
printf("please input the string!\r\n");
scanf("%s",strFile);

readOneFile(strFile,strMatch);
return 0;
}
API之网络函数1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAddConnection3 创建同一个网络资源的连接 WNetCancelConnection 结束一个网络连接 WNetCancelConnection2 结束一个网络连接 WNetCloseEnum 结束一次枚举操作 WNetConnectionDialog 启动一个标准对话框,以便建立同网络资源的连接 WNetDisconnectDialog 启动一个标准对话框,以便断开同网络资源的连接 WNetEnumResource 枚举网络资源 WNetGetConnection 获本地或已连接的一个资源的网络名称 WNetGetLastError 获网络错误的扩展错误信息 WNetGetUniversalName 获网络中一个文件的远程名称以及/或者UNC(统一命名规范)名称 WNetGetUser 获一个网络资源用以连接的名字 WNetOpenEnum 启动对网络资源进行枚举的过程 2. API之消息函数 BroadcastSystemMessage 将一条系统消息广播给系统中所有的顶级窗口 GetMessagePos 得消息队列中上一条消息处理完毕时的鼠标指针屏幕位置 GetMessageTime 得消息队列中上一条消息处理完毕时的时间 PostMessage 将一条消息投递到指定窗口的消息队列 PostThreadMessage 将一条消息投递给应用程序 RegisterWindowMessage 获分配给一个字串标识符的消息编号 ReplyMessage 答复一个消息 SendMessage 调用一个窗口的窗口函数,将一条消息发给那个窗口 SendMessageCallback 将一条消息发给窗口 SendMessageTimeout 向窗口发送一条消息 SendNotifyMessage 向窗口发送一条消息 3. API之文件处理函数 CloseHandle 关闭一个内核对象。其中包括文件、文件映射、进程、线程、安全和同步对象等 CompareFileTime 对比两个文件的时间 CopyFile 复制文件 CreateDirectory 创建一个新目录 CreateFile 打开和创建文件、管道、邮槽、通信服务、设备以及控制台 CreateFileMapping 创建一个新的文件映射对象 DeleteFile 删除指定文件 DeviceIoControl 对设备执行指定的操作 DosDateTimeToFileTime 将DOS日期和时间值转换成一个 win32 FILETIME 值 FileTimeToDosDateTime 将一个 win32 FILETIME 值转换成DOS日期和时间值 FileTimeToLocalFileTime 将一个FILETIME结构转换成本地时间 FileTimeToSystemTime 根据一个FILETIME结构的内容,装载一个SYSTEMTIME结构 FindClose 关闭由FindFirstFile函数创建的一个搜索句柄 FindFirstFile 根据文件名查找文件 FindNextFile 根据调用FindFirstFile函数时指定的一个文件名查找下一个文件 FlushFileBuffers 针对指定的文件句柄,刷新内部文件缓冲区 FlushViewOfFile 将写入文件映射缓冲区的所有数据都刷新到磁盘 GetBinaryType 判断文件是否可以执行 GetCompressedFileSize 判断一个压缩文件在磁盘上实际占据的字节数 GetCurrentDirectory 在一个缓冲区中装载当前目录 GetDiskFreeSpace 获与一个磁盘的组织有关的信息,以及了解剩余空间的容量 GetDiskFreeSpaceEx 获与一个磁盘的组织以及剩余空间容量有关的信息 GetDriveType 判断一个磁盘驱动器的类型 GetExpandedName 得一个压缩文件的全名 GetFileAttributes 判断指定文件的属性 GetFileInformationByHandle 这个函数提供了获文件信息的一种机制 GetFileSize 判断文件长度 GetFileTime 得指定文件的时间信息 GetFileType 在给出文件句柄的前提下,判断文件类型 GetFileVersionInfo 从支持版本标记的一个模块里获文件版本信息
Hello World -- 您的第一个程序 6 C# 程序的一般结构 8 Main() 和命令行自变量 9 命令行自变量 10 显示命令行自变量 12 使用 foreach 存命令行自变量 13 Main() 传回值 14 数据型别 15 在变量宣告中指定型别 16 转型和型别转换 21 Boxing 和 Unboxing 24 使用 as 和 is 运算符进行安全转型 27 将字节数组转换为 int 29 将 string 转换为 int 30 在十六进制字符串和数字型别间转换 32 数组 34 将数组当做对象 35 一维数组 36 多维数组 36 不规则数组 37 在数组上使用 foreach 39 传递数组当做参数 40 使用 ref 和 out 传递数组 42 隐含型别数组 44 字符串 45 字符串基本概念 46 串连多个字符串 53 修改字符串内容 56 比较字符串 60 分割字符串 65 使用字符串方法搜寻字符串 66 使用正则表达式搜寻字符串 67 判断字符串是否表示数值 70 将 String 转换为 DateTime 71 在旧版编码方式和 Unicode 间转换 72 转换 RTF 为纯文本 74 语句、表达式和运算符 75 语句 76 表达式 81 运算符 83 匿名函式 86 Lambda 表达式 88 在查询中使用 Lambda 表达式 92 在 LINQ 之外使用 Lambda 表达式 94 匿名方法 94 可多载的运算符 97 转换运算符 98 使用转换运算符 99 在结构之间实作用户定义的转换 101 使用运算符多载建立复数类别 103 覆写 Equals() 和运算符 == 的方针 105 类别和结构 108 类别 112 对象 115 结构 118 使用结构 119 继承 122 多型 126 使用 Override 和 New 关键词进行版本控制 132 了解使用 Override 和 New 关键词的时机 135 覆写 ToString 方法 137 抽象和密封类别以及类别成员 138 定义抽象属性 140 静态类别和静态类别成员 144 成员 148 存修饰词 149 字段 151 常数 153 在 C# 中定义常数 155 属性 156 使用属性 157 接口属性 165 非对称存子的存范围 168 宣告和使用读/写入属性 173 自动实作的属性 176 使用自动实作的属性来实作轻量型类别 176 方法 177 传递参数 181 传递实值型别的参数 181 传递参考型别的参数 184 了解传递结构和传递类别参考给方法之间的差异 187 隐含型别局部变量 188 在查询表达式中使用隐含型别局部变量和数组 191 扩充方法 192 实作和呼叫自定义扩充方法 197 建立列举型别的新方法 199 建构函式 200 使用建构函式 201 实例建构函式 204 私用建构函式 209 静态建构函式 211 撰写复制建构函式 213 对象和集合初始化表达式 217 初始化对象但不呼叫建构函式 219 使用集合初始化表达式来初始化字典 220 嵌套类型 221 部分类别和方法 222 限制 224 匿名型别 227 在查询中传回项目属性的子集 229 界面 230 明确界面实作 232 明确实作接口成员 234 使用继承明确实作接口成员 236 索引器 239 使用索引器 240 界面中的索引器 244 属性与索引器之间的比较 246 使用委派 250 使用具名和匿名方法委派的比较 253 使用委派代接口的时机 255 委派中的 Covariance 和 Contravariance 256 组合委派 (多播委派) 258 宣告、产生和使用委派 259 事件 264 订阅及消订阅事件 265 发行符合 .NET Framework 方针的事件 267 在衍生类别中引发基类事件 271 实作界面事件 276 使用字典储存事件实例 280 实作自定义事件存子 283 泛型 284 泛型简介 285 泛型的优点 287 泛型型别参数 289 泛型类别 295 泛型界面 298 泛型方法 304 泛型和数组 306 泛型委派 307 泛型程序代码中的默认关键词 308 C++ 样板和 C# 泛型之间的差异 309 运行时间中的泛型 310 .NET Framework 类别库中的泛型 311 泛型和反映 312 泛型和属性 313 泛型型别中的变异数 314 LINQ 查询表达式 325 查询表达式基本概念 328 在 C# 中撰写 LINQ 查询 336 查询对象集合 339 从方法传回查询 341 将查询的结果储存在内存中 343 使用各种不同方式分组结果 344 将群组包含在群组中 352 针对分组作业执行子查询 353 在运行时间动态指定述词筛选条件 362 执行内部联结 364 执行群组联结 372 执行左外部联接 376 排序 Join 子句的结果 378 使用复合索引键执行联结 381 执行自定义联结作业 382 处理查询表达式中的 Null 值 387 处理查询表达式中的例外状况 388 Iterator 390 使用 Iterator 392 建立整数清单的 Iterator 区块 394 建立泛型清单的 Iterator 区块 395 命名空间 398 使用命名空间 399 使用命名空间别名限定符 403 使用 My 命名空间 405 可为 Null 的型别 407 使用可为 Null 的型别 409 Box 处理可为 Null 的型别 413 识别可为 Null 的型别 414 从 bool? 安全转型至 bool 415 Unsafe 程序代码和指标 415 固定大小缓冲区 416 使用 Windows ReadFile 函式 417 指标型别 421 指标转换 422 指标表达式 424 得指针变量值 424 得变量地址 425 使用指标存成员 426 使用指针存数组元素 428 管理指标 429 递增和递减指标 429 指标的算术运算 430 指标比较 431 使用指针复制字节数组 432 XML 文件批注 434 建议使用的文件批注标签 435 处理 XML 档案 448 文件标签的分隔符 453 使用 XML 文件功能 454 应用程序域 458 在其他应用程序域中执行程序代码 459 建立和使用应用程序域 461 组件和全局程序集缓存 461 Friend 组件 462 判断档案是否为组件 465 加载和卸除组件 466 与其他应用程序共享程序集 466 使用属性 468 明示属性目标 470 使用反映存属性 472 使用属性建立 C/C++ 等位 475 常见属性 476 全局属性 479 集合类别 483 使用 foreach 存集合类别 484 使用例外状况 489 例外处理 492 建立和掷回例外状况 495 编译程序所产生的例外状况 498 使用 try/catch 处理例外状况 498 使用 finally 执行清除程序代码 499 拦截非 CLS 例外状况 501 文件系统和登录 502 逐一查看目录树状结构 502 得档案、文件夹和磁盘驱动器的信息 509 建立档案或文件夹 509 写入文本文件 515 从文本文件读 516 一次一行读文本文件 (Visual C#) 516 在登录中建立机码 (Visual C#) 517 写入应用程序事件记录文件 (Visual C#) 518 互操作性 518 使用平台调用播放 WAV 檔 520 范例 COM 类别 523 线程 524 使用线程 525 线程同步处理 526 建立和结束线程 530 同步处理产生者和消费者线程 534 使用线程集区 542 反映 545 C# DLL 547 建立和使用 C# DLL 547 安全性 550

5,530

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 模式及实现
社区管理员
  • 模式及实现社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧