[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

[Solved] C# LINQ queries within queries and selecting groups

The first method should use this method: https://msdn.microsoft.com/en-us/library/vstudio/bb549393(v=vs.100).aspx Something like: return students.GroupBy(student => student.Level, (level, students) => new Tuple(level, students.Count())); Sorry I’m unable to test this, but basically like your version I’m using a lambda to say Group all students by level. The second lambda tells the method what to do with those groups. In … Read more