晨风资讯网
新闻资讯网络冲浪网页设计网络编程图形图像数据库网络媒体服务器网络安全网站运营软件教程黑客认证Wap技术
教程搜索
教程搜索:
  首页 > 网络编程 > C# 教程 > 正文  

Visual C# .NET 入门
日期:2005-6-13 17:37:00 来源:网络 作者:无名 浏览:



为了方便起见,我们提供了完整的源程序和项目文件。您可以通过本文档顶部的目录来访问它们。

其他资源
我们强烈推荐下面这些关于 C# 和 .NET 平台的书籍。它们是开发人员尝试学习这些新技术的有益资源。

• Archer, Tom.Inside C#.Redmond:Microsoft Press, 2001.

• Deitel, Harvey.C#:How to Program.Upper Saddle River, NJ:Prentice Hall, 2001.

• Gunnerson, Eric.A Programmer's Introduction to C#.New York:Apress, 2000.

• Platt, David.Introducing Microsoft .NET.Redmond:Microsoft Press, 2001.



补遗:QuickSort C# .NET 的源代码
下面是 QuickSort C# .NET 示例应用程序的完整源代码。您可以复制、使用和分发这些代码(无版权费)。注意,这些源代码以"原样"提供并且不作任何保证。

//
// QuickSort C# .NET Sample Application
// Copyright 2001-2002 Microsoft Corporation. All rights reserved.
//
// MSDN ACADEMIC ALLIANCE [http://www.msdn.microsoft.com/academic]
// This sample is part of a vast collection of resources we developed for
// faculty members in K-12 and higher education. Visit the MSDN AA web site for more!
// The source code is provided "as is" without warranty.
//
// Import namespaces
using System;
using System.Collections;
using System.IO;
// Declare namespace
namespace MsdnAA
{
// Declare application class
class QuickSortApp
{
// Application initialization
static void Main (string[] szArgs)
{
// Print startup banner
Console.WriteLine ("\nQuickSort C#.NET Sample Application");
Console.WriteLine ("Copyright (c)2001-2002 Microsoft Corporation. All rights reserved.\n");
Console.WriteLine ("MSDN ACADEMIC ALLIANCE [http://www.msdnaa.net/]\n");
// Describe program function
Console.WriteLine ("This example demonstrates the QuickSort algorithm by reading an input file,");
Console.WriteLine ("sorting its contents, and writing them to a new file.\n");
// Prompt user for filenames
Console.Write ("Source: ");
string szSrcFile = Console.ReadLine ();
Console.Write ("Output: ");
string szDestFile = Console.ReadLine ();
// Read contents of source file
string szSrcLine;
ArrayList szContents = new ArrayList ();
FileStream fsInput = new FileStream (szSrcFile, FileMode.Open, FileAccess.Read);
StreamReader srInput = new StreamReader (fsInput);
while ((szSrcLine = srInput.ReadLine ()) != null)
{
// Append to array
szContents.Add (szSrcLine);
}
srInput.Close ();
fsInput.Close ();
// Pass to QuickSort function
QuickSort (szContents, 0, szContents.Count - 1);
// Write sorted lines
FileStream fsOutput = new FileStream (szDestFile, FileMode.Create, FileAccess.Write);
StreamWriter srOutput = new StreamWriter (fsOutput);
for (int nIndex = 0; nIndex < szContents.Count; nIndex++)
{
// Write line to output file
srOutput.WriteLine (szContents[nIndex]);
}
srOutput.Close ();
fsOutput.Close ();
// Report program success
Console.WriteLine ("\nThe sorted lines have been written to the output file.\n\n");
}
// QuickSort implementation
private static void QuickSort (ArrayList szArray, int nLower, int nUpper)
{
// Check for non-base case
if (nLower < nUpper)
{
// Split and sort partitions
int nSplit = Partition (szArray, nLower, nUpper);
QuickSort (szArray, nLower, nSplit - 1);

本教程共6页,当前在第5页  1  2  3  4  5  6  


上一篇: UBB(c#完整版) 下一篇:

C#中ToString()的常见用法

返回列表 打印此页 加入收藏 资讯论坛 关闭窗口 点击复制本页地址,发送给QQ/MSN好友
关于我们 - 联系我们 - 版权声明 - 帮助(?) - 广告服务 - 友情链接 - 服务项目 - 人才招聘
2003-2008 版权所有 © 晨风资讯网 未经授权禁止复制或建立镜像
CopyRight 2003-2008 www.Net118.com,All Rights Reserved.Design By ChenFeng Network Studio