标签: valueconverter

从List <Integer>转换为array float []

我有一个列表如下:

List<Integer> arrInt={2,3,5};
Run Code Online (Sandbox Code Playgroud)

我想将这个arraylist转换为数组float.

float[] result={2,3,5};
Run Code Online (Sandbox Code Playgroud)

我的代码:

    public float[] convertIntToFloat(List<Integer> arr)
    {
      List<Float> arrResult=new ArrayList<Float>();

      for(int i=0;i<arr.size();i++)
      {
        float x=i;
        arrResult.add(x);
      }

      float result[]=arrResult.toArray( new float[arr.size()]);  //Error

      return result;
    }
Run Code Online (Sandbox Code Playgroud)

但它在我的代码中显示错误,如上所述.你能帮助我吗?

java arraylist valueconverter

0
推荐指数
1
解决办法
3782
查看次数

C++小字符到十六进制函数?

我正在尝试找到一种非常轻量级的方法,可以使用下面的两个示例对一个char或md5进行挖掘.

char example[0x34];
char example_final[0x200];
sprintf(example, "%s", "4E964DCA5996E48827F62A4B7CCDF045");
Run Code Online (Sandbox Code Playgroud)

有关使用以下两个PHP函数的示例.

MD5:

sprintf(example_final, "%s", md5(example));
output: 149999b5b26e1fdeeb059dbe0b36c3cb
Run Code Online (Sandbox Code Playgroud)

HEX:

sprintf(example_final, "%s", bin2hex(example));
output: 3445393634444341353939364534383832374636324134423743434446303435
Run Code Online (Sandbox Code Playgroud)

这是最轻量级的做法.我正在考虑一些大的char值,它的十六进制值比制作一个循环foreach char,但不确定.

c++ hex md5 valueconverter

0
推荐指数
1
解决办法
5205
查看次数

Decimal.TryParse - 缺少分隔符?

I have strange situation, when I use API. I get object in JSON, which I deserialize. This object contains string property which is parsed to decimal.

To do this I use this code. I live in Poland where decimal separator is ',', so I use replace method.

string input ="160.00"; //value from API

decimal result;
decimal.TryParse(input.Replace('.',','), out result);
Run Code Online (Sandbox Code Playgroud)

From time to time I result is equals 16000!! (I suppose TryParse method delete separator, it not determined). How can I prevent …

.net c# decimal tryparse valueconverter

0
推荐指数
2
解决办法
633
查看次数

将String转换为int返回NumberFormatException

我从API接收下一个字符串:

String userId = "4463570100035744";
Run Code Online (Sandbox Code Playgroud)

我需要将它转换为int,所以我尝试了下一个代码:

try {
     int id = Integer.parseInt(userId);
} catch (NumberFormatException e){
     e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

但我还是抓住了......

可能是什么原因?

android exception valueconverter numberformatexception

0
推荐指数
1
解决办法
86
查看次数

将用户流入的美元转换为100美元的账单和1000美元的账单

我正在做一个学校项目,我需要知道如何将用户输入的美元转换成100美元的账单和1000美元的账单和剩余的美元.让我们说你在商店,你想要尽可能高的账单支付你的物品,所以假设你必须支付9853美元.我如何打印多少10美元,5美元钞票,10美元钞票,50美元钞票,100美元钞票和1000美元钞票?

尽可能支付高额费用.没变.

$ 9853将是:9x $ 1000票据,8x $ 100票据,1x $ 50票据和3x $ 1票据.

如果有人对此有答案请回答,任何答案都非常有帮助.谢谢.

c# visual-studio-2010 valueconverter

-4
推荐指数
1
解决办法
252
查看次数