[Solved] Program Design Idea c#

Mabe you are looking for something like this: class ProductionStep { public string name; public decimal calculatCosts() { return 100; } } List<ProductionStep> listOfAllProductionstep; private void button5_Click(object sender, EventArgs e) { List<ProductionStep> psList = new List<ProductionStep>(); psList.Add(listOfAllProductionstep.Find(o => o.name == “Abc”)); psList.Add(listOfAllProductionstep.Find(o => o.name == “Def”)); decimal totalCosts = 0; foreach (ProductionStep ps in psList) … Read more

[Solved] Parsing xml in string [duplicate]

I’d use LINQ to XML, with a helper method: var movies = from element in XDocument.Parse(xml).Descendants(“Movie”) select new Class1 { Id = (int) element.Attribute(“ID”), Subject = (string) element.Element(“Name”), OtherName = (string) element.Element(“OtherName”), Duration = (int) element.Element(“Duration”) .Attribute(“Duration”), Property1 = (string) element.Element(“Properties”) .Elements(“Property”) .Where(x => (string) x.Attribute(“Name”) == “Property1”) .Single(), Property2 = (string) element.Element(“Properties”) .Elements(“Property”) .Where(x … Read more

[Solved] C++: Using for loop I need to take infinite values of a point using arrays. How can I take values of point [ ] until 2 points of are equal

To test if two consecutive numbers are equal, you dont need 100 elements, you need 2: int points[2], counter = 1; // Read in first point: cin >> points[0]; // Read until we meet our condition: do { // Read a point into the next part of the array. cin >> points[counter]; // toggle counter … Read more

[Solved] C++ append to existing file [duplicate]

You can’t. Files don’t really have lines, they just store a bunch of characters/binary data. When you have 1,2,3,4,5 6,7,8,9,0 It only looks that was because there is an invisible character in there that tells it to write the second line to the second line. The actual data in the file is 1,2,3,4,5\n6,7,8,9,0 So you … Read more

[Solved] Generating list in a following format [closed]

Something like this would work var results = from x in context.Tests group x by new { x.DeptId, x.StudentId, x.TeacherId } into grp select new { grp.Key.DeptId, grp.Key.StudentId, grp.Key.TeacherId, A = grp.FirstOrDefault(x => x.TestName == “A”)?.TestValue, B = grp.FirstOrDefault(x => x.TestName == “B”)?.TestValue }; This requires C# 6 for the null-conditional operator ?., but you … Read more

[Solved] Vigenere Cipher logic error

There are several problems with your code: You’re error checking isn’t correct. You check if(argc!=2||!apha) after you’ve already evaluated strlen(argv[1]) — by then it’s too late! Check the validity of argc before accessing argv and don’t double up the argument count error and alphabetic key error, they’re independent. Also, error messages should go to stderr, … Read more

[Solved] Overloaded C++ function float parameters error [duplicate]

The function call func(1.14, 3.33) is ambiguous because 1.14 and 3.33 are doubles and both can be converted to either int or float. Therefore the compiler does not know which function to call. You can fix this by explicitly specifying the type of the constants func(float(1.14), float(3.33)) or by changing the overload from func(float, float) … Read more

[Solved] Why is DateTime.TryParse making my number into a Date?

public static class DBNullExt { public static string DBNToString(this object value) { if (value == System.DBNull.Value) return null; else { string val = value.ToString(); DateTime test; string format = “MM/dd/yyyy h:mm:ss tt”; if (DateTime.TryParseExact(val, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out test)) return test.ToShortDateString(); else return val; } } } As a string, 3685.02 or 2014.10 is an … Read more

[Solved] Why does my program stop with an error message?

As already stated in the comments and solved by the OP: when checking the number of arguments, you may not continue and use the arguments anyway if the check fails. To pass arguments to the program from within VS, see this question. solved Why does my program stop with an error message?

[Solved] Select a part in a string C# [closed]

Assuming your string will always have only two -s, you could using the following to get the substring between them. If this is not the case please modify the question to better describe the issue. string myString = AccountName.Split(‘-‘)[1]; Check out https://msdn.microsoft.com/en-us/library/system.string.split(v=vs.110).aspx for more information on the Split method in the string class. 1 solved … Read more

[Solved] in C#, a method who gives me a list of months and year between two dates [closed]

This function will do it. What it returns is a series of dates – the first day of each month which is part of the range. public IEnumerable<DateTime> GetMonths(DateTime startDate, DateTime endDate) { if(startDate > endDate) { throw new ArgumentException( $”{nameof(startDate)} cannot be after {nameof(endDate)}”); } startDate = new DateTime(startDate.Year, startDate.Month, 1); while (startDate <= … Read more