[Solved] regex to exact match 11 digit phone number from string and remove hyphen(-) from match in c#

You can use below Regex to remove all hyphens and all other non numeric characters from phone number string pattern = @”\b([\-]?\d[\-]?){11}\b”; Regex rgx = new Regex(pattern); var sentence = “This is phone number 0341-2239548 and 021-34223311″; var matches = rgx.Matches(sentence); foreach (Match match in matches) { string replacedValue = Regex.Replace(match.Value, @”[^0-9]”, “”); sentence = … Read more

[Solved] How to collect all exceptions of application when its work complete?

It really depends on how you are currently handling all those exceptions. You can take a look at the AppDomain.UnhandledException and AppDomain.FirstChanceException (documentation here) events. The latter should provide notification of all managed exceptions before they get passed to a normal exception handler. Using either that or your current exceptions handlers you will have to … Read more

[Solved] Using ProgressBar for specific time [closed]

Maybe you want something like this: public void AnimateProgBar (int milliSeconds) { if (!timer1.Enabled) { progressBar1.Value = 0; timer1.Interval = milliSeconds / 100; timer1.Enabled = true; } } private void timer1_Tick(object sender, EventArgs e) { if (progressBar1.Value < 100) { progressBar1.Value += 1; progressBar1.Refresh(); } else { timer1.Enabled = false; } } Then you just … Read more

[Solved] How can i format and add a string // in any place after a directory?

Adding addition / characters is reasonably easy if you are certain the URLs are consistent – you can use a mixture of a Uri object to conveniently section the URL for you, combined with the string Replace() method: class Program { static void Main(string[] args) { var myUri = new Uri(“ftp://ftp.newsxpressmedia.com/Images/CB 967×330.jpg”); var modifiedUri = … Read more

[Solved] Use List of custom Business Objects as ComboBox datasource

public class MyClass { public string FirstProperty { get; set; } public int SecondProperty { get; set; } } Then: var myList = new List<MyClass> { new MyClass {SecondProperty = 1, FirstProperty = “ABC”}, new MyClass {SecondProperty = 2, FirstProperty = “ZXC”} }; comboBox1.DataSource = myList; comboBox1.ValueMember = “FirstProperty”; comboBox1.DisplayMember = “SecondProperty”; I hope it … Read more

[Solved] How do I transfer a list from between two Forms? [closed]

The type you’re passing is: List<macivari> The type the constructor expects is: List<string> These are not the same type. If Form2 needs a List<macivari>, then it should expect one: public List<macivari> Freezers=new List<macivari>(); public Form2(List<macivari> a) { InitializeComponent(); Freezers = a; foreach (var item2 in Freezers) { } } If, on the other hand, it … Read more

[Solved] c# windows form in form as part of the ihm

Im’ really sorry guys, yeah i just had to make my borderstyle none. Really sorry to made you loose your time, and thanks for the answer Reports rep = new Reports(); rep.FormBorderStyle = FormBorderStyle.None; rep.MdiParent = this; rep.Show(); solved c# windows form in form as part of the ihm