.Net code samples

==Basic==

using System.IO;

static FileInfo[] GetXls()
{
List<string> l = new List<string>();
DirectoryInfo di = new DirectoryInfo("info");
return di.GetFiles("*.xls");//.ToList().ForEach(x => l.Add(x));
//return l;
}

using System.Reflection;

public static string StartupPath
{
get
{
string AssemblyLocation = Assembly.GetEntryAssembly().Location;
string startupPath = System.IO.Path.GetDirectoryName(AssemblyLocation) + "\\";
return startupPath;
}
}

==Regex==

" "/"-"+"中文":Regex.Match(name, "(?<=[ -])[\u0800-\u9fa5]+").Value;

==Office Interop==

Microsoft.Office.Interop.Excel.Application app_xls = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Word.Application app_doc = new Microsoft.Office.Interop.Word.Application();

Microsoft.Office.Interop.Excel.Workbook wb_result = app_xls.Workbooks.Open(StartupPath + "201109.xlsx", Editable: true);
Worksheet ws_result = wb_result.Sheets["auto"];
int ws_result_StartEditingRow = ws_result.UsedRange.Rows.Count + 1;
Console.WriteLine("wb_result Start writing from Row " + ws_result_StartEditingRow);

Microsoft.Office.Interop.Excel.Range xls_names = ws_result.UsedRange.Columns[1];
object[,] xls_names_value = null;
if (ws_result.UsedRange.Rows.Count > 1)
xls_names_value = (object[,])xls_names.get_Value();

((Microsoft.Office.Interop.Excel.Range)ws_result.Cells[ws_result_StartEditingRow, 1]).set_Value(Missing.Value, wb_single.Name.ToString());

Document document = app_doc.Documents.Open(doc, ReadOnly: true);

int count = document.FormFields.Count;  //FormFields is for restrict editing

wb_result.Save();
wb_result.Close(SaveChanges: true);
app_doc.Quit();
app_xls.Quit();

==LINQ==

var mc_group = from Match m in mc

let m_labor = m.Groups["labor"].ToString()

group m_labor by m_labor into mg

orderby mg.Count ()

select mg;

foreach (var m in mc_group)

m.Key

==Debug==

.NET Debugging Demos - Information and setup instructions: http://blogs.msdn.com/b/tess/archive/2008/02/04/net-debugging-demos-information-and-setup-instructions.aspx

[2010-11-17T22:22:01+08:00] netmon filter: property.SoapAction.contains("Tree")

==Samples==

Symptom: Cross-thread operation not valid: Control " " accessed from a thread other than the thread it was created on.
Workaround: Control.CheckForIllegalCrossThreadCalls = false;

[2010-10-27t23:30:42+08:00] datetime.now.tostring("yyyymmdd_hhmmss");

[2010-11-03T19:50:00+08:00] match non-English :
[^u0000-u0080]+
[^\x00-\x80]+

[2011-03-23T22:14:00+08:00] Managed Windows API http://mwinapi.sourceforge.net/

==ASP.Net==

[2010-10-26t20:05:18+08:00] asp.net page_load if (!ispostback)

[2010-10-29T23:19:43+08:00] IIS  HTTP Error 500.19 - Internal Server Error  - 0x80070021 : http://learn.iis.net/page.aspx/145/how-to-use-locking-in-iis-70-configuration

[2010-11-09T19:12:41+08:00] IIS error - Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list - %windir%\Microsoft.NET\Framework\v4.0.xxxx\aspnet_regiis.exe -i

[2010-11-09T19:17:59+08:00] IIS ApplicationPoolIdentity http://www.codetoday.net/default.aspx?g=posts&t=1595

[2010-11-17T22:50:14+08:00] DebugDiag for IIS

[2010-12-16T13:36:19+08:00]  Sudden Error: Could not load type System.ServiceModel.Activation.HttpModule    C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -iru

==Problems to solve==

[2010-11-12T09:52:49+08:00] [p to solve] ( () () ) | \2 \1

==C++==

[2011-01-06T16:12:38+08:00] http://www.codeproject.com/KB/cpp/PtrToPtr.aspx

在Visual Studio Code中,代码高亮是通过插件方式实现的。Visual Studio Code本身只是提供了一套架子,而插件则负责实现代码高亮等功能。插件可以通过声明式和编程式两种方式扩展语言的支持。 声明式接口是基于TextMate的,可以快速识别代码中的词法。通过声明式接口,插件可以指定不同的颜色和样式来高亮不同的代码元素。 编程式接口包括了LSP(Language Server Protocol),它提供了更高级的功能,如错误提示、代码补齐、跳转定义等。通过LSP,插件可以实现更复杂的代码分析和处理。 如果你对LSP感兴趣,你可以参考Visual Studio Code官方示例来学习,这个示例是一个LSP的样例项目,可以帮助你更好地理解和使用LSP技术。你可以通过以下命令来获取示例项目:git clone https://github.com/microsoft/vscode-extension-samples.git,然后进入lsp-sample目录并编译运行。 综上所述,Visual Studio Code通过插件提供了丰富的代码高亮功能,可以通过声明式和编程式接口来扩展语言的支持和功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [你不知道的 VSCode 代码高亮原理](https://blog.csdn.net/LuckyWinty/article/details/117677856)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值