[Solved] How to copy Data from one class to another [closed]

To keep it simple and answer your question, here is the code needed. The anticipated issues? I’ve commented the line I am most skeptical about, I hope you’re considering another design because this design somewhat resembles a recipe for disaster. This answer however should set you on the right path, you can implement further null … Read more

[Solved] Visual Studio said my variables are useless in a private method [closed]

Because these parameters are not being passed by reference, setting them to any value will only change the value of the parameter variables local to your helper method: it will not impact the values that were passed in to those parameters. Since you don’t use the new values you’re assigning to those parameters inside the … 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] Why this is not possible in C#? [closed]

Looks like an interesting case on what is allowed as a generic parameter type name. This: class DoesSomething<T> : IDoSomething<string> { public void Dispose() { } } and this class DoesSomething<T> : IDoSomething<String> { public void Dispose() { } } is obvious. Here T is used as a generic parameter name. On the other hand … Read more

[Solved] Unable to Render ContentControl inside Window [closed]

Set the DataContext property of the window: <Window x:Class=”MimicView.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ xmlns:local=”clr-namespace:MimicView” mc:Ignorable=”d” d:DataContext=”{d:DesignInstance local:MainWindowViewModel}” Title=”MainWindow” Height=”350″ Width=”525″> <Window.Resources> <DataTemplate DataType=”{x:Type local:ViewModel1}”> <local:View1/> </DataTemplate> </Window.Resources> <Window.DataContext> <local:MainWindowViewModel /> </Window.DataContext> <Grid> <ContentControl Content=”{Binding viewModel1}”></ContentControl> </Grid> </Window> This only sets the design time DataContext: d:DataContext=”{d:DesignInstance local:MainWindowViewModel}” You should also set the actual DataContext property: <Window.DataContext> … 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] How split string in c#? (no, not string.split() :) [closed]

this code produces expected result: s.Trim(‘\”) .Split(new[]{“‘,'”}, StringSplitOptions.RemoveEmptyEntries) it removes 1st and last ‘ symbols and splits by ‘,’ output Malaysia Index Mc’DONALDS CORPORATION McDonalds Me,dia 2 solved How split string in c#? (no, not string.split() 🙂 [closed]

[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] Searching folders and subfolders for a file and get its size depending on the name

string adPicturesPath = ConfigurationManager.AppSettings[“AdPicturesPath”]; List<string> files = new List<string> { “235253325_23522.jpg” }; var allFiles = files.SelectMany(fn => Directory.EnumerateFiles(adPicturesPath, fn, System.IO.SearchOption.AllDirectories)); long allFileSizeBytes = allFiles.Sum(fn => new FileInfo(fn).Length); 1 solved Searching folders and subfolders for a file and get its size depending on the name