我正在用C#编写一个简单的控制台应用程序。
在class TourAgency:
def __init__(self):
self._tours = {}
self._scheduledtours = {}
self._customers = {}
self._booking = {}
def addTour(self,code,tour):
self._tours[code] = tour
def addscheduledtours(self,code,scheduledtour):
self._scheduledtours[code] = scheduledtour
def addCustomer(self,code,customer):
self._customers[code] = customer
def addBooking(self,bookingId,booking):
self._booking[bookingId] = booking
def searchscheduledtours(self,code):
if code in self.scheduledtours.keys():
return self._scheduledtours[code]
else:
return None
mytour = TourAgency()
t1 = Tour("KO111","Discover Korea",8,7,1449.36)
print(t1)
ta = mytour.addTour('KO111',t1)
print(TourAgency.tours)
或System或System.Core程序集中的其他任何地方,找不到Console.ReadKey()的任何等效异步方法。
从Stdout异步读取键的内置函数吗?
我已经在.NET Framework 4.7.2和.NET Core 2.1中使用了C#7.3。但是问题是在.NET Framework,.NET Core,Mono等任何平台上的任何当前或将来版本的C#。
专家的注释:我知道如何手动实现它,因此,我不需要任何示例代码。另外,我不想为此立即添加任何其他库。我只是要求提供信息而不是解决方法。
答案 0 :(得分:0)
C#中似乎没有自然的方法可以帮助您做到这一点。为了解决这个问题,我尝试了以下两种方法:
Console.ReadKey()
。 Ref on stack overflow 根据您的情况,您可以选择一个。