int

Cannot implicitly convert type 'void' to 'int'?

天涯浪子 提交于 2020-02-15 05:55:04
问题 Oke so I am fairly new to programming and I don't get why I get this error. My method should store mails which it does in this method: public void StoreMail(PhishingMail PhishingMail) { using (var phishingMailStorage = new PhishFinderModel()) { phishingMailStorage.PhishingMail.Attach(PhishingMail); phishingMailStorage.SaveChanges(); } And then in my processPhishingMail method it calls the Store method. But then I get the error: Cannot implicitly convert type 'void' to 'int'. public void

Cannot implicitly convert type 'void' to 'int'?

怎甘沉沦 提交于 2020-02-15 05:54:07
问题 Oke so I am fairly new to programming and I don't get why I get this error. My method should store mails which it does in this method: public void StoreMail(PhishingMail PhishingMail) { using (var phishingMailStorage = new PhishFinderModel()) { phishingMailStorage.PhishingMail.Attach(PhishingMail); phishingMailStorage.SaveChanges(); } And then in my processPhishingMail method it calls the Store method. But then I get the error: Cannot implicitly convert type 'void' to 'int'. public void

Java Compare 2 integers with equals or ==?

岁酱吖の 提交于 2020-02-11 14:14:32
问题 i am very very new to Java and i would like to know how can i compare 2 integers? I know == gets the job done.. but what about equals? Can this compare 2 integers? (when i say integers i mean "int" not "Integer"). My code is: import java.lang.*; import java.util.Scanner; //i read 2 integers the first_int and second_int //Code above if(first_int.equals(second_int)){ //do smth } //Other Code but for some reason this does not work.. i mean the Netbeans gives me an error: "int cannot be

Java Compare 2 integers with equals or ==?

旧城冷巷雨未停 提交于 2020-02-11 14:14:06
问题 i am very very new to Java and i would like to know how can i compare 2 integers? I know == gets the job done.. but what about equals? Can this compare 2 integers? (when i say integers i mean "int" not "Integer"). My code is: import java.lang.*; import java.util.Scanner; //i read 2 integers the first_int and second_int //Code above if(first_int.equals(second_int)){ //do smth } //Other Code but for some reason this does not work.. i mean the Netbeans gives me an error: "int cannot be

Convert a list of floats to the nearest whole number if greater than x in Python

烈酒焚心 提交于 2020-02-05 11:15:50
问题 I'm new to Python and I did my research but didn't get far, hence the post for help. I have a list of floats which I would like to round to the nearest whole number ONLY if the element is greater than 0.50. list = [54.12,86.22,0.30,0.90,0.80,14.33,0.20] expected outcome: list = [54,86,0.30,1,1,14,0.20] 回答1: use the python conditional expression: [round(x) if x > 0.5 else x for x in lst] e.g.: >>> [round(x) if x > 0.5 else x for x in lst] [54.0, 86.0, 0.3, 1.0, 1.0, 14.0, 0.2] To get it

How java converts int to boolean

ぐ巨炮叔叔 提交于 2020-02-02 04:10:31
问题 When i convert: int B=1; boolean A=B; It gives error: Incompatible types, which is true But when I write this code: int C=0; boolean A=C==1; it gives false while if I change value of C to 1 it gives true. I don't understand how compiler is doing it. 回答1: int C=0; boolean A=C==1; The compiler first gives C a zero. Variable : C Value : 0 Now The Assignment statement, We know that the assignment statement evaluates the right part first and the gives it to the left. The right part ==> C == 1 Here

Removing duplicate digits in an integer [closed]

断了今生、忘了曾经 提交于 2020-02-02 03:19:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have faced this program in technical round. They have give this program to me for removing duplicate digits in given integer without using arrays or strings . Example: int i = 123134254; Expected output: 12345 回答1: You can use an int as a set to store the digits you've already encountered by assigning each

Can a variable be initialized with an istream on the same line it is declared? [duplicate]

﹥>﹥吖頭↗ 提交于 2020-02-01 00:43:07
问题 This question already has answers here : Are there any tricks to use std::cin to initialize a const variable? (6 answers) Closed 2 years ago . Can the following two lines be condensed into one? int foo; std::cin >> foo; 回答1: The smart-ass answer: int old; std::cin >> old; The horrible answer: int old, dummy = (std::cin >> old, 0); The proper answer: old has to be defined with a declaration before it can be passed to operator>> as an argument. The only way to get a function call within the

What does parseInt do exactly?

旧城冷巷雨未停 提交于 2020-01-30 13:29:06
问题 What does parseInt do exactly? 回答1: A String cannot be used like an int. With parseInt you can convert a string to an int. public class Program { public static void main(String[] args) { String value = "1000"; // Parse with parseInt: the string can be negative. int result = Integer.parseInt(value); System.out.println(result); System.out.println(result + 1); 来源: https://stackoverflow.com/questions/35264666/what-does-parseint-do-exactly

Error when attempting to use max_element to figure out the highest number in an array

帅比萌擦擦* 提交于 2020-01-30 13:17:48
问题 int a = max_element(highesthuman[0], highesthuman[2]); if( win > loss) { cout << "You won " << (win-loss) << " games more than the computer did! You used " << a << " the most."; } } The above array is given by int humanrock = 0; int humanpaper = 0; int humanscissors = 0; int highesthuman [3] = {humanrock, humanpaper, humanscissors}; When running my whole program I get an error saying "invalid type argument of unary". I looked this up but was not able to understand "pointers" or what people