Форум программистов, компьютерный форум, киберфорум
RunningMan
Войти
Регистрация
Восстановить пароль
Оценить эту запись

Запись

Запись от RunningMan размещена 21.08.2017 в 17:04

.NET Core
Вызов функции в зависимости от операционной системы:

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Runtime.InteropServices;
 
[DllImport("msvcrt.dll",EntryPoint = "system",CallingConvention = CallingConvention.Cdecl, SetLastError=true)]
static extern int WinSystem(string command);
 
[DllImport("libc.so.6",EntryPoint = "system",SetLastError = true)] 
static extern int LinSystem(string command);
 
 static void Main(string[] args)
{               
     //  console clear
 
    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
         WinSystem("cls");
    else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
         LinSystem("clear");
    else
         throw new NotSupportedException();
 }
Размещено в Без категории
Показов 1215 Комментарии 0
Всего комментариев 0
Комментарии
 
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2023, CyberForum.ru