[Solved] This logic statement is as short as possible

[ad_1] The conditional operator is intended to be used with assignments, not as a generalized replacement for the if/else statements. This is because it produces a result (it is an expression), and that result is then assigned to something else. For example, consider the following statement: var a = x != null ? x : … Read more

[Solved] Entity Framework c#

[ad_1] The issue is with these 2 lines: i2.Prodajalna.Add(new Prodajalna() { imeProdajalne = “Nekaj2”, naslovProdajalne = “Koper” }); i3.Prodajalna.Add(new Prodajalna() { imeProdajalne = “Nekaj2”, naslovProdajalne = “Koper” }); What you really want is to create a single Prodajalna and reuse it. The simplest way to accomplish this is to save the object first, and the … Read more

[Solved] foreach loop syntax error C# Visual Studio 2013 ultimate

[ad_1] I’m not 100% sure about this, but your foreach is between your try and catch block, maybe try with that: try { string filename = “../../” + filenametxt.Text; StreamReader inputFile = File.OpenText(filename); while(!inputFile.EndOfStream) { studentansArray[index] = inputFile.ReadLine(); if (studentansArray[index] == answerArray[index]) count++; else { qnumber = index + 1; incorrectList.Add(qnumber.ToString()); } index++; } inputFile.Close(); … Read more

[Solved] Index and length must refer to a location within the string ASP.NET [duplicate]

[ad_1] I think you are looking for String.Insert Returns a new string in which a specified string is inserted at a specified index position in this instance. So simply use return name.Insert(extPos, “_180x140”); However as per your error is concerned use return name.Substring(0, extPos) + “_180x140” + name.Substring(extPos); [ad_2] solved Index and length must refer … Read more

[Solved] Search a Number [closed]

[ad_1] I’ll not provide a complete solution for you but here is a basic idea that you can work with. You could convert the numbers into strings and then count the number of times you can find one string in the other. Here are some of the basic function you can use. This should get … Read more

[Solved] Is there a way to define Variadic template macro?

[ad_1] __VA_ARGS__ can be used multiple times, so you could write: #define PARSE_FUNCTION(functionName, …) \ std::function<int(__VA_ARGS__)> m_##functionName() { \ return std::function<int(__VA_ARGS__)>(functionName); \ } What is happening is just simple text substitution, whether the arguments is for a template or not won’t be checked by the preprocessor. Actually any function objects can be implicitly converted to … Read more

[Solved] C++ How can I access to an inner enum class?

[ad_1] P0W’s answer is correct on both counts, but in case you simply want to output the underlying value, then it may be simpler to cast rather than overload the insertion operator. using enum_type = std::underlying_type<Apple::color>::type; enum_type value = (enum_type)Apple::color::green; std::cout << value << ‘\n’; 2 [ad_2] solved C++ How can I access to an … Read more