電商類網(wǎng)站開發(fā)百度指數(shù)怎么提升
上一篇:
C#,入門教程(06)——解決方案資源管理器,代碼文件與文件夾的管理工具https://blog.csdn.net/beijinghorn/article/details/124895033
創(chuàng)建新的 C# 項目后, Visual Studio 會自動創(chuàng)建一系列的目錄與文件。
程序員后面的工作就是在這個目錄及這些文件的基礎(chǔ)上進行的。
本文對這些目錄與文件做一個概要性的解釋。
一、目錄
1、默認(rèn)的目錄
Visual Studio 默認(rèn)創(chuàng)建 3 個子目錄及下層的目錄。
\bin
\---Debug
\---Release
\obj
\---Debug
\---Release
\Properties
\bin 目錄保存項目生成的程序集(.exe 或 .dll)
\bin\Debug 保存“調(diào)式版本Debug”模式的文件,一般都是在這個目錄下能找到可執(zhí)行文件 .exe
\bin\Release ?保存“正式發(fā)布版本Release”模式的文件
\obj 目錄保存項目的編譯臨時文件(一般無需操心)
\obj\Debug 保存“調(diào)式版本Debug”模式的文件
\obj\Release 保存“正式發(fā)布版本Release”模式的文件
\Properties 目錄保存項目相關(guān)的一些設(shè)置信息,一般無需閱讀與修改。
2、改良與更好的目錄結(jié)構(gòu)
建議在工程目錄下創(chuàng)建 App_Code 子目錄,用以保存工程相關(guān)的所有 namespace 的 class 文件。
并且按類別予以區(qū)分。比如,幸運之門50018.COM的目錄結(jié)構(gòu):
\App_Code
\App_Code\Basic ?存儲常用的 Helper 類的基礎(chǔ)靜態(tài)類
\App_Code\K50018 存儲核心數(shù)據(jù)分類代碼
\App_Code\K50018\Basic 數(shù)據(jù)分析的基礎(chǔ)代碼
\App_Code\K50018\Entity 數(shù)據(jù)體(從數(shù)據(jù)庫、文件獲得)的相關(guān)代碼
\App_Code\K50018\Algorithm 數(shù)據(jù)分析的算法代碼
\App_Code\K50018\Graph 生成走勢圖表等分析結(jié)果的代碼
。。。
請,舉一反三!
二、文件
工程相關(guān)的文件分類兩類:(1)*.cs 是C#源代碼類;(2)*.else 其他類;
1、.sln 解決方案(solution)文件
.sln 是解決方案的配置文件,保存著項目project和解決方案的關(guān)系。
這個文件也是雙擊打開 Visual Studio 的默認(rèn)文檔。
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop", "Desktop.csproj", "{D87DE9F7-951F-4392-A24B-64DF168191CA}"
EndProject
。。。
2、.csproj 工程項目(C sharp project)文件
.csproj 為c sharp project的縮寫。
.csproj 項目文件,保存著源代碼、其他文檔、資源和本項目的歸屬關(guān)系。
用編輯器(推薦韓國人寫的Editplus!)打開 Desktop.csproj 文件,可以看到類似這樣的(XML)內(nèi)容:
。。。
<ItemGroup><Compile Include="App_Code\K50018\Basic\Statistics.cs" /><Compile Include="App_Code\K50018\Algorithm\Prime.cs" /><Compile Include="App_Code\K50018\Graph\Trend.cs" />
。。。<Compile Include="Form1.cs"><SubType>Form</SubType></Compile><Compile Include="Form1.Designer.cs"><DependentUpon>Form1.cs</DependentUpon></Compile><Compile Include="Program.cs" />
。。。
3、App.config 項目配置文件
App.config 一般是這樣的XML內(nèi)容。
<?xml version="1.0" encoding="utf-8" ?>
<configuration><startup>?<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup>
</configuration>
4、Form 相關(guān)文件
(1)Form 相關(guān)
Form 是指軟件的窗口。Form 相關(guān)文件是3個一組。
Form1.cs (窗口事件處理的)源代碼
Form1.Designer.cs 窗口設(shè)計的源代碼(初學(xué)者略過)
Form1.resx 窗口設(shè)計的資源信息(初學(xué)者掠過)
Form1.cs 一般是這樣的內(nèi)容:
// 引用系統(tǒng)的命名空間
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows.Forms;// 引用自己開發(fā)的命名空間
using Legalsoft.K50018;namespace Desktop_Application
{public partial class Form1 : Form{// 默認(rèn)構(gòu)造函數(shù)public Form1(){InitializeComponent();}// 窗口加載時候的處理private void Form1_Load(object sender, EventArgs e){}// button1 點擊事件的處理private void button1_Click(object sender, EventArgs e){//一般的代碼都從這里起飛!}}
}
Form1.Designer.cs的內(nèi)容一般這樣:
namespace Desktop_Application
{partial class Form1{/// <summary>/// 必需的設(shè)計器變量。/// </summary>private System.ComponentModel.IContainer components = null;/// <summary>/// 清理所有正在使用的資源。/// </summary>/// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows 窗體設(shè)計器生成的代碼/// <summary>/// 設(shè)計器支持所需的方法 - 不要修改/// 使用代碼編輯器修改此方法的內(nèi)容。/// </summary>private void InitializeComponent(){this.panel1 = new System.Windows.Forms.Panel();this.button1 = new System.Windows.Forms.Button();this.panel2 = new System.Windows.Forms.Panel();this.webBrowser1 = new System.Windows.Forms.WebBrowser();this.panel1.SuspendLayout();this.panel2.SuspendLayout();this.SuspendLayout();。。。}}
}
Form1.resx 窗口設(shè)計的資源信息(初學(xué)者掠過)
<?xml version="1.0" encoding="utf-8"?>
<root><!--?Microsoft ResX Schema?Version 2.0The primary goals of this format is to allow a simple XML format?that is mostly human readable. The generation and parsing of the?various data types are done through the TypeConverter classes?associated with the data types.。。。-->
</root>
(2)更多的窗口
如果軟件設(shè)計有多個窗口,則就具有多個配套的文件。常見的有:
歡迎窗口
Welcome.cs (窗口事件處理的)源代碼
Welcome.Designer.cs 窗口設(shè)計的源代碼(初學(xué)者略過)
Welcome.resx 窗口設(shè)計的資源信息(初學(xué)者掠過)
軟件配置窗口
Setting.cs (窗口事件處理的)源代碼
Setting.Designer.cs 窗口設(shè)計的源代碼(初學(xué)者略過)
Setting.resx 窗口設(shè)計的資源信息(初學(xué)者掠過)
軟件幫助窗口
Help.cs (窗口事件處理的)源代碼
Help.Designer.cs 窗口設(shè)計的源代碼(初學(xué)者略過)
Help.resx 窗口設(shè)計的資源信息(初學(xué)者掠過)
再見!
Bye.cs (窗口事件處理的)源代碼
Bye.Designer.cs 窗口設(shè)計的源代碼(初學(xué)者略過)
Bye.resx 窗口設(shè)計的資源信息(初學(xué)者掠過)
三、更多的項目!!!
壓軸的,都是精彩的!
《幸運之門彩票網(wǎng)50018.COM》 有這樣一系列的實際需求:
(1)網(wǎng)站:運行于 Windows Server 2008 之 IIS 的 Web 服務(wù);
? ? ?需要 App_Code 下的所有代碼支持的功能;
(2)合作:運行于合作伙伴 Linux 之 Web 服務(wù);
? ? ?需要 App_Code 下的所有代碼支持的功能;
(3)桌面PC:《藍(lán)彩和app》;
? ? ?需要 App_Code 下的所有代碼支持的功能;
(4)安卓(Andriod)App:《藍(lán)彩和app》;
? ? ?需要 App_Code 下的所有代碼支持的功能;
(5)蘋果(iOS)App:《藍(lán)彩和app》;
? ? ?需要 App_Code 下的所有代碼支持的功能;
(6)合作伙伴Unity游戲軟件內(nèi)的《CaiPiao分析》;
? ? ?需要 App_Code 下的主要代碼支持的功能;
于是,在我的工程目錄下就有了這樣一些文件:
App.config
Desktop.csproj 桌面PC軟件
Desktop.sln
Web.csproj IIS網(wǎng)站,WEB服務(wù)
Web.sln
Linux.csproj LINUX,WEB服務(wù)
Linux.sln
MAPP-Andriod.csproj 安卓app
MAPP-Andriod.sln
MAPP-iOS.csproj 蘋果app
MAPP-iOS.sln
Unity.csproj 游戲Unity app
Unity.sln
Form1.cs
Form1.Designer.cs
Form1.resx
Welcome.cs
Welcome.Designer.cs
Welcome.resx
Setting.cs
Setting.Designer.cs
Setting.resx
Help.cs
Help.Designer.cs
Help.resx
Bye.cs
Bye.Designer.cs
Bye.resx
重要的是!僅僅只需要維護一個 App_Code !!!
C# 是無與倫比的!
下一篇:
C#,入門教程(08)——基本數(shù)據(jù)類型及使用的基礎(chǔ)知識https://blog.csdn.net/beijinghorn/article/details/123906998
?