{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/csharp-code-toolkit/",
  "atlas": "https://www.pystone.net/?node=csharp-code-toolkit#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/csharp-code-toolkit.md",
  "context": "https://www.pystone.net/notes/csharp-code-toolkit.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:csharp-code-toolkit",
  "slug": "csharp-code-toolkit",
  "title": "CSharp代码工具集",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "CSharp代码工具集",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "417d6d321d179bb282659665a87c97baf102fe6b8de13c1f75ddb871ec9a4c07",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "CSharp代码工具集",
      "anchor": "csharp代码工具集",
      "citation": "https://www.pystone.net/notes/csharp-code-toolkit/#csharp%E4%BB%A3%E7%A0%81%E5%B7%A5%E5%85%B7%E9%9B%86"
    },
    {
      "depth": 2,
      "text": "获取函数的调用栈信息",
      "anchor": "获取函数的调用栈信息",
      "citation": "https://www.pystone.net/notes/csharp-code-toolkit/#%E8%8E%B7%E5%8F%96%E5%87%BD%E6%95%B0%E7%9A%84%E8%B0%83%E7%94%A8%E6%A0%88%E4%BF%A1%E6%81%AF"
    },
    {
      "depth": 2,
      "text": "判断操作系统类型",
      "anchor": "判断操作系统类型",
      "citation": "https://www.pystone.net/notes/csharp-code-toolkit/#%E5%88%A4%E6%96%AD%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%B1%BB%E5%9E%8B"
    },
    {
      "depth": 2,
      "text": "枚举类型扩展方法",
      "anchor": "枚举类型扩展方法",
      "citation": "https://www.pystone.net/notes/csharp-code-toolkit/#%E6%9E%9A%E4%B8%BE%E7%B1%BB%E5%9E%8B%E6%89%A9%E5%B1%95%E6%96%B9%E6%B3%95"
    },
    {
      "depth": 2,
      "text": "监听目录下文件的改动",
      "anchor": "监听目录下文件的改动",
      "citation": "https://www.pystone.net/notes/csharp-code-toolkit/#%E7%9B%91%E5%90%AC%E7%9B%AE%E5%BD%95%E4%B8%8B%E6%96%87%E4%BB%B6%E7%9A%84%E6%94%B9%E5%8A%A8"
    },
    {
      "depth": 2,
      "text": "实时获取手机电流、电压、计算功率发热",
      "anchor": "实时获取手机电流电压计算功率发热",
      "citation": "https://www.pystone.net/notes/csharp-code-toolkit/#%E5%AE%9E%E6%97%B6%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E7%94%B5%E6%B5%81%E7%94%B5%E5%8E%8B%E8%AE%A1%E7%AE%97%E5%8A%9F%E7%8E%87%E5%8F%91%E7%83%AD"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:programming-languages-and-runtimes",
      "title": "编程语言与运行时",
      "url": "https://www.pystone.net/notes/programming-languages-and-runtimes/",
      "atlas": "https://www.pystone.net/?node=programming-languages-and-runtimes#knowledge-atlas",
      "label": "编程语言与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": ".NET与CSharp中的“CSharp代码工具集”导航项",
      "citation": "https://www.pystone.net/notes/programming-languages-and-runtimes/#net%E4%B8%8Ecsharp"
    }
  ],
  "contentMarkdown": "# CSharp代码工具集\n\n﻿# CSharp代码工具集\n\n> 创建时间：2024/1/13 19:02\n\n* 获取函数的调用栈信息\n  * 判断操作系统类型\n  * 枚举类型扩展方法\n  * 监听目录下文件的改动\n  * 实时获取手机电流、电压、计算功率发热\n\n## 获取函数的调用栈信息\n\n1.(new StackTrace()).GetFrame(1) // 0为本身的方法；1为调用方法\n2.(new StackTrace()).GetFrame(1).GetMethod().Name; // 方法名\n3.(new StackTrace()).GetFrame(1).GetMethod().ReflectedType.Name; // 类名\n\n```csharp\nstring str1 = &quot;test&quot;;\nstring str2 = &quot;test&quot;;\n\n```\n\n## 判断操作系统类型\n\n操作系统| PlatformID| 主版本号| 副版本号\n---|---|---|---\nWindows95| 1| 4| 0\nWindows98| 1| 4| 10\nWindowsMe| 1| 4| 90\nWindowsNT3.5| 2| 3| 0\nWindowsNT4.0| 2| 4| 0\nWindows2000| 2| 5| 0\nWindowsXP| 2| 5| 1\nWindows2003| 2| 5| 2\nWindowsVista| 2| 6| 0\nWindows7| 2| 6| 1\n\n```csharp\nstring str1 = &quot;test&quot;;\nstring str2 = &quot;test&quot;;\n\n```\n\nSystem.PlatformID枚举值及其含义\nWin32S 操作系统为 Win32s（Win32 子集）类型。\nWin32s 是运行于 Windows 16 位版本上的层，它提供对 32 位应用程序的访问。\nWin32Windows 操作系统为 Windows 95 或较新的版本。\nWin32NT 操作系统为 Windows NT 或较新的版本。\nWinCE 操作系统为 Windows CE。\nUnix 操作系统为 Unix。\nXbox 开发平台为 Xbox 360。\n\n```csharp\nstring str1 = &quot;test&quot;;\nstring str2 = &quot;test&quot;;\n\n```\n\n## 枚举类型扩展方法\n\n```csharp\nstring str1 = &quot;test&quot;;\nstring str2 = &quot;test&quot;;\n\n```\n\n## 监听目录下文件的改动\n\nRef: https://blog.csdn.net/xingxiupaioxue/article/details/82901403\n\n```csharp\nstring str1 = &quot;test&quot;;\nstring str2 = &quot;test&quot;;\n\n```\n\nRef: https://blog.csdn.net/wojiaoxiaol/article/details/4084997\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n在Unity中实现\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n## 实时获取手机电流、电压、计算功率发热\n\nhttps://www.xuanyusong.com/archives/4753\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n"
}
