如何使用'Type'类型(How to use the type 'Type')
我知道我可以使用类型
string
:string someString = "This is my string";
我不知道如何使用
Type
Type someType = someString.GetType();
我怎样才能根据该类型创建变量。 我想做点什么
someType someOtherString = "here is another string"; //string
换句话说,我怎么能根据某种类型创建变量?
I know that I can use the type
string
as:string someString = "This is my string";
I am not sure how to use the type
Type
Type someType = someString.GetType();
How could I create a variable based on that type. I want to do something like
someType someOtherString = "here is another string"; //string
In other words, how could I create a variable based on some type?
原文:https://stackoverflow.com/questions/6103172
更新时间:2023-08-23 12:08
最满意答案
如果您想在设置
MediaElement
后立即开始播放,我建议您将其AutoPlay
属性设置为true。 这应该工作! :)If you want to inmediately start playing after the
MediaElement
is set, I would suggest you to put itsAutoPlay
property to true. This should work! :)
相关问答
更多-
initialize的承诺同步运行。 虽然$http请求没有。 这导致调用$scope.function2而不等待$scope.function1来解析。 它应该是 $scope.function1= function () { return $http... }; $scope.function2= function () { return $http... }; 在这种情况下,延迟的promise 是antipattern ,而initialize应该简洁如下: var initi ...
-
同步运行功能(Running functions synchronously)[2021-05-30]
您可以将回调函数发送到您的requestAddress函数,并在请求完成后调用它。 根据需要发回参数 - 我已经创建了回调函数作为isValid的匿名函数,但是如果您愿意,它可以是一个单独的命名函数。 function requestAddress(urlCombined, callback) { request(urlCombined, function (error, response, body) { a = JSON.parse(body); c = ... -
从API同步获取数据(Getting Data from API synchronously)[2022-01-07]
您正在同步发出请求。 这意味着发出请求的线程将停止,直到您获得结果。 问题是,由于您的UI正在启动请求,因此整个UI线程(刷新UI)正在等待服务器的响应。 如果您想同步执行请求,而不暂停UI线程,则必须使用Task (或任何其他允许您在另一个线程上运行请求的对象) var t = new Task(getData); //create the task, and tell it to run your method t.Start(); //launch it 任务实例将允许您获取有关正在运行的任务的信息 ... -
你可以调用getValue()来返回当前值(如果有的话)。 但是,没有“阻止直到有价值”选项。 大多数情况下,这是因为LiveData意图在主应用程序线程上使用,其中要避免无限期阻塞调用。 如果需要“阻塞直到有值”,请使用RxJava并确保在后台线程上观察。 You can call getValue() to return the current value, if there is one. However, there is no "block until there is a value" opti ...
-
同步使用requirejs(Using requirejs synchronously)[2023-11-03]
在这里回答我自己的问题。 看了很久之后,我看不到任何方法同步加载Requirejs代码或加载后立即调用模块。 所以我最终编写了一些代码来临时覆盖require和declare方法。 它适用于我的用例,但如果其他人需要它可能需要更改。 我确信它可以比现在更优化,但它确实有效。 您可以在GitHub上找到我将尝试维护的代码。 此时的代码如下所示: (function () { var self = {}, originalDefine = window.define, o ... -
NSStream是一个抽象类,既不会将数据读取也不会将数据写入流中。 要实际访问数据,您需要一个具体的子类,例如NSInputStream或NSOutputStream (或NSOutputStream的自定义子类)。 要读取NSInputStream的数据,请调用read:maxLength: . 您可能希望使用hasBytesAvailable轮询流,询问是否有任何新数据可用。 NSOutputStream具有类似的write:maxLength:和hasSpaceAvailable方法。 iOS文档强 ...
-
同步运行AdaptiveMediaSource.CreateFromUriAsync(Running AdaptiveMediaSource.CreateFromUriAsync synchronously)[2023-07-30]
如果您想在设置MediaElement后立即开始播放,我建议您将其AutoPlay属性设置为true。 这应该工作! :) If you want to inmediately start playing after the MediaElement is set, I would suggest you to put its AutoPlay property to true. This should work! :) -
public override IGFlowLayoutViewCell CreateCell(IGFlowLayoutView flowLayoutView, nint index) { IGFlowLayoutViewCell cell = flowLayoutView.DequeueReusableCell("CELL") as IGFlowLayoutViewCell; UIImageView iconImage = new UIIma ...
-
同步和异步之间的主要区别是异步不等待。 您必须学习如何以全新的方式编写代码,以确保以正确的顺序发生事情。 值得学习如何做到这一点,但它起初可能有点大脑弯曲。 fs.readFileSync(file); // Stops and waits for completion. console.log("This will always print after fs.readFileSync."); fs.readFile(file, function callback(err, data) { // Does ...
-
您不应该使本机异步方法同步,而是使您的调用站点异步。 也就是说,您的方法变为异步并提供完成处理程序: - (void) userWithUsername:(NSString *)username password:(NSString *)password completion:(completion_handler_t)completion; 其中completion_handler_t是一个类型定义,可以在头文件中声明如下: typed ...