我有webApi给我一个blob文件,我必须显示.我怎么知道我得到的斑点是什么类型的?它可以是任何东西,pdf,doc,jpeg等.
$http({ method: 'GET', url: (itemsUrl), responseType: 'arraybuffer' }).then(function mySucces(res) {
var byteArray = res.data;
byteArray = new Uint8Array(byteArray);
var file = new Blob([byteArray], { type: '??????' });
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});
Run Code Online (Sandbox Code Playgroud)
或者,如何在不知道文件类型的情况下在新窗口中打开blob?
我有on change触发事件:
$(document).on('change', '.class', function (eve) {
Run Code Online (Sandbox Code Playgroud)
如何通过事件变量知道更改是来自鼠标还是来自键盘?
我有try和catch的代码.
try
{
//Some Code...
}
catch (Exception err)
{
throw err;
}
Run Code Online (Sandbox Code Playgroud)
我想知道的是编写这样的代码是否有优势.从catch中抛出exeption并编写try和catch而不是从破坏的行中获取错误.
提前致谢
我有字典,键是一个int数组,值是一个字符串.如何通过检查是否int包含在密钥数组中来获取值?
public static Dictionary<int[], string> MyDic = new Dictionary<int[], string>
{
{new int[]{2,25},"firstValue"},
{new int[]{3,91,315,322},"secondValue"}
};
Run Code Online (Sandbox Code Playgroud)
我有 :
int number=91;
string value=?;
Run Code Online (Sandbox Code Playgroud)
我需要价值得到 "secondValue"
c# ×2
angularjs ×1
arrays ×1
dictionary ×1
events ×1
javascript ×1
jquery ×1
onchange ×1
try-catch ×1