{"id":479,"date":"2022-10-27T19:40:41","date_gmt":"2022-10-27T16:40:41","guid":{"rendered":"https:\/\/ru.robotnet.org\/blog\/?post_type=docs&#038;p=479"},"modified":"2023-01-06T19:18:14","modified_gmt":"2023-01-06T16:18:14","slug":"csharp-sample-hello-world","status":"publish","type":"docs","link":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/","title":{"rendered":"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world"},"content":{"rendered":"\n<p><strong>sdk\\c-sharp\\hello-world\\hello-world\\Program.cs<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code console-output has-small-font-size\"><code>using System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\nusing System.Reflection;\r\n\r\n#if (DEBUG)\r\nusing RobotNET.Factory.Debug;\r\n#else\r\nusing RobotNET.Factory.Release;\r\n#endif\r\n\r\nnamespace HelloWorld\r\n{\r\n    class Program\r\n    {\r\n        static void Main( string&#91;] args )\r\n        {\r\n            Console.WriteLine( string.Format( \"Program started!\" ) );\r\n\r\n            Console.WriteLine( string.Format( \"Caller environment current directory: {0}\", Environment.CurrentDirectory ) );\r\n            Console.WriteLine( string.Format( \"Caller domain base directory: {0}\", AppDomain.CurrentDomain.BaseDirectory ) );\r\n\r\n            try\r\n            {\r\n#if (DEBUG)\r\n                using( Factory factory = new Factory( args&#91;0], args&#91;1], \"sdk\\\\c-sharp\\\\hello-world\\\\hello-world-plugin\\\\bin\\\\debug\\\\hello-world-plugin.dll\", \"HelloWorld.Plugin\" ) )\r\n#else\r\n                using( Factory factory = new Factory( args&#91;0], args&#91;1], \"sdk\\\\c-sharp\\\\hello-world\\\\hello-world-plugin\\\\bin\\\\release\\\\hello-world-plugin.dll\", \"HelloWorld.Plugin\" ) )\r\n#endif\r\n                    try\r\n                    {\r\n                        string current_directory = factory.Read();\r\n                        Console.WriteLine( current_directory );\r\n\r\n                        string base_directory = factory.Read();\r\n                        Console.WriteLine( base_directory );\r\n\r\n                        Console.Write( \"Your greeting: \" );\r\n                        string read = Console.ReadLine();\r\n                        factory.Write( read );\r\n                        string s = factory.Read();\r\n                        Console.WriteLine( string.Format( \"Program received \\\"{0}\\\"\", s ) );\r\n                    }\r\n                    catch( Exception e )\r\n                    {\r\n                        Console.WriteLine( string.Format( \"Program catch an error at Main \\\"{0}\\\"\", e ) );\r\n                    }\r\n            }\r\n            catch( Exception e )\r\n            {\r\n                Console.WriteLine( e );\r\n            }\r\n\r\n            Console.WriteLine( string.Format( \"Program finished!\" ) );\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<p><strong>sdk\\c-sharp\\hello-world\\hello-world-plugin\\Plugin.cs<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code console-output has-small-font-size\"><code>using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.ComponentModel;\r\nusing System.Diagnostics;\r\n\r\nusing RobotNET.Factory;\r\n\r\nnamespace HelloWorld\r\n{\r\n    public class Plugin : MarshalByRefObject, IPlugin\r\n    {\r\n        public void Worker( object _pipe )\r\n        {\r\n            \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u0440\u0438\u0431\u0438\u0432\u0430\u044e\u0442\u0441\u044f\r\n            \/*ProcessStartInfo si = new ProcessStartInfo( \"cmd.exe\" );\r\n            si.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;\r\n            si.CreateNoWindow = false;\r\n            si.UseShellExecute = true;\r\n            Process.Start( si );*\/\r\n\r\n            \/\/ \u041f\u043e\u0442\u043e\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0443\u0448\u0435\u043d \u043f\u0430\u0439\u043f\r\n            IPipe pipe = ( IPipe )_pipe;\r\n\r\n            Console.WriteLine( string.Format( \"Plugin started!\" ) );\r\n\r\n            pipe.Write( string.Format( \"Plugin environment current directory: {0}\", Environment.CurrentDirectory ) );\r\n            pipe.Write( string.Format( \"Plugin domain base directory: {0}\", AppDomain.CurrentDomain.BaseDirectory ) );\r\n\r\n            string s = pipe.Read();\r\n\r\n            Console.WriteLine( string.Format( \"Plugin received \\\"{0}\\\"\", s ) );\r\n\r\n            pipe.Write( string.Format( \"You are welcome! Oops! (Reply for &lt;{0}>)\", s ) );\r\n\r\n            Console.WriteLine( string.Format( \"Plugin finished!\" ) );\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>sdk\\c-sharp\\hello-world\\hello-world\\Program.cs sdk\\c-sharp\\hello-world\\hello-world-plugin\\Plugin.cs<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[33],"doc_tag":[],"class_list":["post-479","docs","type-docs","status-publish","hentry","doc_category-c-sharp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world - \u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/\" \/>\n<meta property=\"og:locale\" content=\"ru_RU\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world - \u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET\" \/>\n<meta property=\"og:description\" content=\"sdkc-sharphello-worldhello-worldProgram.cs sdkc-sharphello-worldhello-world-pluginPlugin.cs\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-06T16:18:14+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 \u043c\u0438\u043d\u0443\u0442\u0430\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/\",\"url\":\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/\",\"name\":\"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world - \u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET\",\"isPartOf\":{\"@id\":\"https:\/\/ru.robotnet.org\/blog\/#website\"},\"datePublished\":\"2022-10-27T16:40:41+00:00\",\"dateModified\":\"2023-01-06T16:18:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/#breadcrumb\"},\"inLanguage\":\"ru-RU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\/\/ru.robotnet.org\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ru.robotnet.org\/blog\/#website\",\"url\":\"https:\/\/ru.robotnet.org\/blog\/\",\"name\":\"\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f RobotNET\",\"description\":\"\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u041f\u0438\u0440\u0438\u043d\u0433\u043e\u0432\u043e\u0439 \u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u041c\u0438\u043a\u0440\u043e-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 RobotNET\",\"alternateName\":\"\u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ru.robotnet.org\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ru-RU\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world - \u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/","og_locale":"ru_RU","og_type":"article","og_title":"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world - \u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET","og_description":"sdkc-sharphello-worldhello-worldProgram.cs sdkc-sharphello-worldhello-world-pluginPlugin.cs","og_url":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/","og_site_name":"\u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET","article_modified_time":"2023-01-06T16:18:14+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f":"1 \u043c\u0438\u043d\u0443\u0442\u0430"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/","url":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/","name":"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world - \u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET","isPartOf":{"@id":"https:\/\/ru.robotnet.org\/blog\/#website"},"datePublished":"2022-10-27T16:40:41+00:00","dateModified":"2023-01-06T16:18:14+00:00","breadcrumb":{"@id":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/#breadcrumb"},"inLanguage":"ru-RU","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ru.robotnet.org\/blog\/doc\/c-sharp\/csharp-sample-hello-world\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/ru.robotnet.org\/blog\/"},{"@type":"ListItem","position":2,"name":"9.3.2. \u041f\u0440\u0438\u043c\u0435\u0440 Hello world"}]},{"@type":"WebSite","@id":"https:\/\/ru.robotnet.org\/blog\/#website","url":"https:\/\/ru.robotnet.org\/blog\/","name":"\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f RobotNET","description":"\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u041f\u0438\u0440\u0438\u043d\u0433\u043e\u0432\u043e\u0439 \u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u041c\u0438\u043a\u0440\u043e-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 RobotNET","alternateName":"\u0411\u043b\u043e\u0433, \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f RobotNET","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ru.robotnet.org\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ru-RU"}]}},"_links":{"self":[{"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/docs\/479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/comments?post=479"}],"version-history":[{"count":0,"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/docs\/479\/revisions"}],"wp:attachment":[{"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/media?parent=479"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/doc_category?post=479"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/ru.robotnet.org\/blog\/wp-json\/wp\/v2\/doc_tag?post=479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}