[Solved] C++ PNG Decoder Error

The error is self-explanatory. You are not passing in the correct parameters that decode() is expecting. Look at the actual declaration of the decode() overload that you are trying to call (there are 3 overloads available): unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const std::string& filename, LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8); … Read more

[Solved] Task and return type [closed]

About the first part of the question: You return Task or Task if your method does a I/O call, or a long running CPU intensive calculation and you don’t want the caller thread to be blocked while this operation is being performed. You return void or a direct value in your method doesn’t fit the … Read more

[Solved] Search value in csv file using c# [closed]

You can create a function to do this task as below: String GetAddress(String searchName) { var strLines=File.ReadLines(“filepath.csv”); foreach(var line in strLines) { if(line.Split(‘,’)[1].Equals(searchName)) return line.Split(‘,’)[2]; } return “”; } you can call the above function as below: String peterAddress=GetAddress(“Peter”); EDIT: String address=””; Dictionary<String, String> dict_Name_Address = new Dictionary<string, string>(); var lines=File.ReadLines(“FileName.csv”); foreach (var line in … Read more

[Solved] Can’t use ‘contains’ in LINQ [closed]

You are facing problem on this line (result => result.SiteUrl.Contains(last.ToString()); Can you please check that SiteUrl is type of string otherwise it not going to work for you. because last is type of string and Contains is method supported by string type … or otherwise last need to be enumebrable collection and siteurl also enumerable … Read more

[Solved] How to instantiate objects dynamically in C# [closed]

Keep references to your objects with a list: var myobjects = new List<System.Security.Cryptography.MD5>(); for (var i = 0; i < 100; i++) { myobjects.Add(System.Security.Cryptography.MD5.Create()); } and iterate through the list: for (var i = 0; i < 100; i++) { myobjects[i].ComputeHash(new byte[] { (byte)i }); Console.WriteLine(BitConverter.ToString( myobjects[i].Hash)); } Otherwise Reusing the same variable will make … Read more

[Solved] How to call third party Restful API [closed]

The problem is that you are mixing up options of the library with HTTP headers. Try with this instead: public static void Main (string[] args) { string url = “https://dashboard.reviewpush.com/api/company/locations”; using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = “application/json”; client.Headers[“X-Api-Key”] = “key”; client.Headers[“X-Api-Secret”] = “secret”; string s = client.DownloadString(url); Console.WriteLine(s); } } You might … Read more

[Solved] Semicolon/String constant error

cout <<“Done!” <<fac1 ” multiplied by ” <<fac2 ” equals ” <<prod <<endl; Should be cout <<“Done!” <<fac1 << ” multiplied by ” <<fac2 <<” equals ” <<prod <<endl; And cout <<“Done!” <<divid ” divided by ” <<divis ” equals ” <<quot ” with a remainder of ” <<rem <<endl; Should be cout <<“Done!” <<divid … Read more

[Solved] What can I do to make my program work?

You are missing the closing curly brace (}) at the end of this loop. foreach (string s in tokens) { if (double.TryParse(s, out oneNum)) { nums.Add(oneNum); } else { Console.WriteLine(“You have inputed invalid number, please try again!”); break; } Without that closing brace, all the following calculations are considered to be inside that loop! Since … Read more

[Solved] it is not saving without an image

If your image column allows for null values, change to if(pb1 != null) { MemoryStream stream = new MemoryStream(); pb1.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] pic = stream.ToArray(); command.Parameters.AddWithValue(“@image”, pic); } else { command.Parameters.AddWithValue(“@image”, System.Data.SqlTypes.SqlBinary.Null); // edit: replaced incorreect DBNull.Value due to comment by Heinzi } System.Data.SqlTypes.SqlBinary.Null Currently you are not providing enough parameters to your Sql if … Read more

[Solved] How to convert string into type? [closed]

What you are trying to do with generics is impossible if the type you need is not T. The value that goes where you are asking for needs to be a generic value or a value known at compile time. That means your only choice is: create<T>(root); Or: create<PureTypeName>(root); Or adding other generic parameters. solved … Read more

[Solved] How to extgract an integer and a two dimensional integer array from a combination of both in C#

You could use RegularExpressions for extracting in an easy way each token of your input string. In the following example, support for extra spaces is included also (the \s* in the regular expressions). Remember that always is a great idea to give a class the responsibility of parsing (in this example) rather than taking an … Read more

[Solved] What does no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream’} and ‘float*’) mean? [closed]

What does no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream’} and ‘float*’) mean? [closed] solved What does no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream‘} and ‘float*’) mean? [closed]