所以我看一下System.Console here的源代码。
我认为看看它是如何实现并且可能自己进行一些更改会很有趣。
因此,我直接从Microsoft的示例中复制了源代码,并将其粘贴到Visual Studio中。
它无法编译。
Win32Native.Beep(frequency, duration);
有这样的几行。所有这些都有相同的错误消息。
Error 32 The type or namespace name 'Win32Native' could not be found (are you missing a using directive or an assembly reference?)
大约有一百条错误消息,但只有4条独特的消息。包括上面的主要内容。
Error 85 The name '__Error' does not exist in the current context
Error 89 Cannot take the address of, get the size of, or declare a pointer to a managed type ('Win32Native.CHAR_INFO')
Error 18 The property or indexer 'System.Console.InternalSyncObject' cannot be used in this context because it lacks the get accessor
我强烈怀疑我缺少一些汇编引用。如果你知道它们是什么让我知道,这样我就可以编译它。
答案 0 :(得分:2)
您不知道Microsoft在GitHub上发布了可编译的源代码吗?
https://github.com/dotnet/corefx/tree/master/src/System.Console/src
要进行编译,请按this guide。
背后的理性就是这样,
您现在可以找到https://github.com/dotnet/corefx和https://github.com/dotnet/coreclr。更多的事情即将到来,所以你可以关注http://dotnet.github.io/