[Solved] Method incorrectly being run twice [closed]

[ad_1] When you run CallMethod0, it returns a string. You need to store the result to a string variable, and then Console.Write the variable. Since you have the method call in there twice, it is running twice. In other words, change it to: public static void Main(string[] args) { Console.WriteLine(“Hello world!”); string result = CallMethod0(); … Read more

[Solved] How to sum integer item in List?

[ad_1] Though the other answers supplied are effective enough, I would like to supply a thorough answer to assist at more than just the current syntactical level of C#. For example; Linq wasn’t available prior to 3.5. IS Keyword Checks if an object is compatible with a given type, or (starting with C# 7.0) tests … Read more

[Solved] I don’t understand how ‘i’ become 4 [closed]

[ad_1] In c# assigning a value to a variable also returns a value. Usually it is the value that is assigned Here is an assignment, the current time is assigned to the now variable: DateTime now = DateTime.Now; This assignment also results in a returned value of the current time. It means you can legally … Read more

[Solved] Why we use ‘?’ character in c# [duplicate]

[ad_1] ? is not the operator, the combination of ? and : is the operator, called ‘ternary operator’. The ternary operator is an operator that takes three arguments. The first argument is a comparison argument, the second is the result upon a true comparison, and the third is the result upon a false comparison. If … Read more

[Solved] How to read lines to dictionary with linQ [closed]

[ad_1] The problem is that you need to provide a lambda expression for the second argument of ToDictionary. ToDictionary also returns a Dictionary<T, U> so you won’t be able to assign it to an instance of ConcurrentDictionary<T, U>. This should do the trick: var dicFailedProxies = File.ReadLines(“failed_proxies.txt”) .Distinct() .ToDictionary(line => line, line => 0); Of … Read more

[Solved] display value of database [closed]

[ad_1] Try something like this: Global.dbCon.Open(); List<int> idQuestions = new List<int>(); kalimatSql = kalimatSql; Global.reader = Global.riyeder(kalimatSql); if (Global.reader.HasRows) { while (Global.reader.Read()) { int idQuestion = Convert.ToInt32(Global.reader.GetValue(0)); idQuestions.Add(idQuestion); } } Global.dbCon.Close(); foreach (int id in idQuestions) { messageBox.Show(id.ToString()); } What we are doing here is adding all of the question ids into a list and … Read more

[Solved] Can not Implicitly Convert SymmetrySecurityKey Type [closed]

[ad_1] The error is essentially “Cannot convert from SymmetricSecurityKey(string) to IEnumerable<SymmetricSecurityKey>”. This means that the IssuerSigningKeys is expecting an IEnumerable (List or Array) of SymmetricSecurityKey instead of a single value. The fix is easy, give it an array: services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKeys = new[] { new SymmetricSecurityKey(key) … Read more

[Solved] Need help in mod 1000000007 [closed]

[ad_1] Method 1: Think of how you would compute 500! / (20! * 20! * 20! * …) normally. Don’t multiply everything out and divide at the end. Do your divisions in the middle. Then combine this with the modulus reductions from your previous question. Method 2: Prime factorize 500! and 20!. Then subtract out … Read more

[Solved] printing too much stars [closed]

[ad_1] Should be: #include<stdio.h> int main() { int i, j, n; scanf(“%d”,&n); for (i=0;i<=n;i++){ for (j=0;j<=i;j++){ printf(“*”); } printf(“\n”); } return 0; } You forgot to tell scanf you were reading in an integer by using the %d argument 2 [ad_2] solved printing too much stars [closed]