首页 \ 问答 \ 如何使用'Type'类型(How to use the type 'Type')

如何使用'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 its AutoPlay 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 ...
  • 您可以将回调函数发送到您的requestAddress函数,并在请求完成后调用它。 根据需要发回参数 - 我已经创建了回调函数作为isValid的匿名函数,但是如果您愿意,它可以是一个单独的命名函数。 function requestAddress(urlCombined, callback) { request(urlCombined, function (error, response, body) { a = JSON.parse(body); c = ...
  • 您正在同步发出请求。 这意味着发出请求的线程将停止,直到您获得结果。 问题是,由于您的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代码或加载后立即调用模块。 所以我最终编写了一些代码来临时覆盖require和declare方法。 它适用于我的用例,但如果其他人需要它可能需要更改。 我确信它可以比现在更优化,但它确实有效。 您可以在GitHub上找到我将尝试维护的代码。 此时的代码如下所示: (function () { var self = {}, originalDefine = window.define, o ...
  • NSStream是一个抽象类,既不会将数据读取也不会将数据写入流中。 要实际访问数据,您需要一个具体的子类,例如NSInputStream或NSOutputStream (或NSOutputStream的自定义子类)。 要读取NSInputStream的数据,请调用read:maxLength: . 您可能希望使用hasBytesAvailable轮询流,询问是否有任何新数据可用。 NSOutputStream具有类似的write:maxLength:和hasSpaceAvailable方法。 iOS文档强 ...
  • 如果您想在设置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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。