国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

編程技巧:.Net Framework_.Net教程

2024-07-10 12:49:56
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

推薦:存儲(chǔ)過(guò)程編寫經(jīng)驗(yàn)和優(yōu)化措施
介紹:在數(shù)據(jù)庫(kù)的開(kāi)發(fā)過(guò)程中,經(jīng)常會(huì)遇到復(fù)雜的業(yè)務(wù)邏輯和對(duì)數(shù)據(jù)庫(kù)的操作,這個(gè)時(shí)候就會(huì)用SP來(lái)封裝數(shù)據(jù)庫(kù)操作。如果項(xiàng)目的SP較多,書(shū)寫又沒(méi)有一定的規(guī)范,將會(huì)影響以后的系統(tǒng)維護(hù)困難和大SP邏輯

.Net Framework

1. 如何獲得系統(tǒng)文件夾

使用System.Envioment類的GetFolderPath方法;例如:

Environment.GetFolderPath( Environment.SpecialFolder.Personal )

2. 如何獲得正在執(zhí)行的exe文件的路徑

1) 使用Application類的ExecutablePath屬性

2) System.Reflection.Assembly.GetExecutingAssembly().Location

3. 如何檢測(cè)操作系統(tǒng)的版本

使用Envioment的OSVersion屬性,例如:

OperatingSystem os = Environment.OSVersion;

MessageBox.Show(os.Version.ToString());

MessageBox.Show(os.Platform.ToString());

4. 如何根據(jù)完整的文件名獲得文件的文件名部分

使用System.IO.Path類的方法GetFileName或者GetFileNameWithoutExtension方法

5. 如何通過(guò)文件的全名獲得文件的擴(kuò)展名

使用System.IO.Path.GetExtension靜態(tài)方法

6. Vb和c#的語(yǔ)法有什么不同click here

7. 如何獲得當(dāng)前電腦用戶名,是否聯(lián)網(wǎng),幾個(gè)顯示器,所在域,鼠標(biāo)有幾個(gè)鍵等信息

使用System.Windows.Forms. SystemInformation類的靜態(tài)屬性

8. 修飾Main方法的[STAThread]特性有什么作用

標(biāo)示當(dāng)前程序使用單線程的方式運(yùn)行

9. 如何讀取csv文件的內(nèi)容

通過(guò)OdbcConnection可以創(chuàng)建一個(gè)鏈接到csv文件的鏈接,鏈接字符串的格式是:"Driver={Microsoft Text Driver (*.txt;*.csv)};Dbq=" cvs文件的文件夾路徑 " Extensions=asc,csv,tab,txt; Persist Security Info=False";

創(chuàng)建連接之后就可以使用DataAdapter等存取csv文件了。

詳細(xì)信息見(jiàn)此處

10. 如何獲得磁盤開(kāi)銷信息,代碼片斷如下,主要是調(diào)用kernel32.dll中的GetDiskFreeSpaceEx外部方法。

public sealed class DriveInfo
{
[DllImport("kernel32.dll", EntryPoint = "GetDiskFreeSpaceExA")]
private static extern long GetDiskFreeSpaceEx(string lpDirectoryName,
out long lpFreeBytesAvailableToCaller,
out long lpTotalNumberOfBytes,
out long lpTotalNumberOfFreeBytes);

public static long GetInfo(string drive, out long available, out long total, out long free)
{
return GetDiskFreeSpaceEx(drive, out available, out total, out free);
}

public static DriveInfoSystem GetInfo(string drive)
{
long result, available, total, free;
result = GetDiskFreeSpaceEx(drive, out available, out total, out free);
return new DriveInfoSystem(drive, result, available, total, free);
}
}

public struct DriveInfoSystem
{
public readonly string Drive;
public readonly long Result;
public readonly long Available;
public readonly long Total;
public readonly long Free;

public DriveInfoSystem(string drive, long result, long available, long total, long free)
{
this.Drive = drive;
this.Result = result;
this.Available = available;
this.Total = total;
this.Free = free;
}
}

可以通過(guò)DriveInfoSystem info = DriveInfo.GetInfo("c:");來(lái)獲得指定磁盤的開(kāi)銷情況

11.如何獲得不區(qū)分大小寫的子字符串的索引位置

1)通過(guò)將兩個(gè)字符串轉(zhuǎn)換成小寫之后使用字符串的IndexOf方法:

string strParent = "The Codeproject site is very informative.";

string strChild = "codeproject";

// The line below will return -1 when expected is 4.
int i = strParent.IndexOf(strChild);

// The line below will return proper index
int j = strParent.ToLower().IndexOf(strChild.ToLower());

2) 一種更優(yōu)雅的方法是使用System.Globalization命名空間下面的CompareInfo類的IndexOf方法:

using System.Globalization;

string strParent = "The Codeproject site is very informative.";

string strChild = "codeproject";
// We create a object of CompareInfo class for a neutral culture or a culture insensitive object
CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;

int i = Compare.IndexOf(strParent,strChild,CompareOptions.IgnoreCase);

分享:無(wú)刷新仿google波形扭曲彩色Asp.net驗(yàn)證碼
網(wǎng)上關(guān)于Asp.net驗(yàn)證碼的示例是在不少,前一段時(shí)間我發(fā)布的《51aspx實(shí)現(xiàn)的Asp.net無(wú)刷新中文驗(yàn)證碼》受到了廣大網(wǎng)站的轉(zhuǎn)載,但是關(guān)于其中無(wú)刷新及波形扭曲的文章寥寥無(wú)幾,示例也幾乎難尋,于是

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 伊金霍洛旗| 西宁市| 安义县| 涟水县| 邵武市| 万山特区| 菏泽市| 澳门| 汤阴县| 大竹县| 正定县| 临泽县| 锡林郭勒盟| 巴南区| 定襄县| 大丰市| 邻水| 资源县| 茌平县| 崇文区| 华亭县| 建宁县| 永顺县| 历史| 墨竹工卡县| 长武县| 衡水市| 云霄县| 逊克县| 苍梧县| 旬阳县| 汾西县| 文安县| 甘肃省| 遂宁市| 罗平县| 兴城市| 深圳市| 丹寨县| 磴口县| 龙川县|