gpt4 book ai didi

C#如何自己命名Main()方法?

转载 作者:可可西里 更新时间:2023-11-01 08:16:05 25 4
gpt4 key购买 nike

小问题,有没有办法随心所欲地调用 main 方法?或者它是否必须被称为“Main()”?

最佳答案

请注意,这是 C# 约定,而不是 .NET 运行时约定。您可以在 IL 中随意命名您的方法:

.module Mane.exe
.subsystem 3
.corflags 9

.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89)
.ver 2:0:0:0
}

.assembly Mane
{
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.CLSCompliantAttribute::.ctor(bool) = ( 01 00 01 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 )
.custom instance void [mscorlib]System.Resources.NeutralResourcesLanguageAttribute::.ctor(string) = ( 01 00 05 65 6E 2D 55 53 00 00 )

.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'Execution' = bool(true)}}
.hash algorithm 0x00008004
.ver 1:0:0:0
}

.namespace Mane
{
.class private abstract auto ansi sealed beforefieldinit Program extends [mscorlib]System.Object
{
.method private hidebysig static void Mane() cil managed
{
.entrypoint
.maxstack 1
ldstr "Hello, World!"
call void [mscorlib]System.Console::WriteLine(class System.String)
ret
}
}
}

关于C#如何自己命名Main()方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2610337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com