[Solved] Not able to get sum of array in C#

Your error is from these lines: Console.WriteLine(rea.ReadLine()); ad.Add(Int32.Parse(rea.ReadLine())); What’s happening is you are getting the count of the number of lines in the file. Say your file has 10 lines. When the loop reaches the last line and you call ReadLine method in Console.WriteLine(rea.ReadLine());, it returns the last line. But then you call Readline method … Read more

[Solved] Calculating elapsed time [closed]

You may use the System.Diagnostics.Stopwatch class to time operations precisely in .NET. Dim stopwatch As New Stopwatch() stopwatch.Start() ‘Perform timed operations here stopwatch.Stop() The elapsed TimeSpan may now be retrieved as stopwatch.Elapsed. For a direct analogue to your C code, you would write: Dim elapsed = stopwatch.Elapsed.TotalSeconds 2 solved Calculating elapsed time [closed]

[Solved] C# parameters in interface [closed]

Interfaces are used as a contract for classes that inherit it. This means any public methods/properties you want the interface to expose, must also be exposed in the inherited class. In the case above, you don’t have any public methods/properties exposed in the interface. Let me show you an example. Interface ITest { void AddPerson(string … Read more

[Solved] missing terminating > character at line 17 [closed]

You are code gives segmentation fault because you are accessing memory after array index size. To debug it I simply added two likes in you code to print n, i , j: if(b[i]<a[i]) { for(j=n;j>=i;j–) { a[j+1]=a[j]; } a[i]=b[i]; n = n+1; “<—- 1 Correction need here” printf(“In IF %d %d %d\n”, i, j, n); … Read more

[Solved] How to Save profile account in database when I click the save button? [closed]

Error 31 Cannot implicitly convert type ‘System.Web.UI.WebControls.DropDownList’ to ‘string’ Error 34 Cannot implicitly convert type ‘string’ to ‘System.Web.UI.WebControls.DropDownList’ Exactly as I’ve said in the comments. You can’t use dropdownlists like this. DropDownList has a property for accessing the currently selected value string selectedItemValue = dropDownListInstance.SelectedValue; Or maybe: string selectedItemValue = dropDownListInstance.SelectedItem.Text; 1 solved How to … Read more

[Solved] Random generation of numbers? [closed]

Edit: Original supposition on the problem completely wrong. The cause of you getting all zeros is that the state is not seeded. You need to fill state with something ‘random’. This code work. Note that the function seed() is in absolutely no way scientifically proven to be good – in fact, I just made it … Read more

[Solved] I want to insert a record in DB and then need to return a row

One way to do what you want is to modify @voucherNo to be an OUTPUT parameter, and add a new OUTPUT parameter to your query to return the value of SCOPE_IDENTITY(). @voucherNo varchar(max) @ScopeIdentity numeric(38,0) And modify that last SELECT statement to set the value of @ScopeIdentity parameter. SELECT @ScopeIdentity = SCOPE_IDENTITY() Then use SqlCommand.ExecuteNonQuery … Read more

[Solved] How to override a function without redefine in c#?

You mean you want to call the base constructor from the derived constructor? Yes, you can do that with the base() construct. public Derived(int sides) : base(sides) When Square() actually isn’t a constructor (it is in your question, no return type or void) but a method, you can do it like this: public override returntype … Read more

[Solved] Code is WRONG but no error is raised

What UI frameworks do you use? Some .Net UI Frameworks indeed provide you some “Load” events, but also some happen to SILENCE all exceptions that happen during your even-handlers, “to provide better UI Experience to the end user”. You can check easily if any exceptions are thrown in the OUTPUT panel under debugger. If you … Read more

[Solved] create a regular expression of a specific sentence [closed]

If you’re just asking for a way to parse the variable bits from this kind of text, it’s quite easy: See here: http://tinyurl.com/qjdaj9w var exp = new Regex(@”angle\(Vector\((.*?),(.*?)\),Vector\((.*?),(.*?)\),(.*?),(.*?)\)”); var match = exp.Match(“angle(Vector(JointA,jointB),Vector(JointA,jointB),minValue,maxValue)”); var jointA1 = match.Groups[0]; var jointB1 = match.Groups[1]; var jointA2 = match.Groups[2]; var jointB2 = match.Groups[3]; var max = match.Groups[4]; var min = … Read more

[Solved] Can not pass error via delegate [closed]

Do same null-check as you did when invoked action first time: catch (Exception ex) { if (onError != null) onError(ex); return; } If you want to avoid null-checks – attach dummy handler to Action delegate at the top of your method: onError += (e) => {}; 2 solved Can not pass error via delegate [closed]