c#-4.0

Unboxing for dynamic type

十年热恋 提交于 2020-01-07 08:52:21
问题 Consider the following code: public class Foo1 { public dynamic dowork() { return 10; } } And in my Main , I call like: int i = new Foo1().dowork(); The return value is 10. My question is why no Unboxing is required here?But in watch I've verified the Return Type of dowork is System.Object . 回答1: It is unboxing - but it's doing it implicitly. There's an implicit conversion from any dynamic expression to any type. The exact conversion performed will depend on the execution-time type of the

Forms and Console

烂漫一生 提交于 2020-01-07 05:30:31
问题 I'm Running a forms application and a console application in one application. How can i run the forms application and keep the console closed until i click a button on the form? 回答1: You need to call a couple of win32app calls most specifically allocconsole. here is an msdn post with some sample code. 回答2: You'll need to do a little P/Invoke: Add the appropriate methods: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using

Call method from a parent class and use child class properties

只谈情不闲聊 提交于 2020-01-07 05:10:08
问题 Actual call: ChildClass classCall=new ChildClass(); classCall.FullName="test name"; string returnName=classCall.GetName(); Parent class with method: public class BaseClass { public string GetName() { // I can request the value of the property like this. return this.GetType().GetProperty("FullName") .GetValue(this, null).ToString(); } } Child class: public partial class ChildClass : BaseClass { public string FullName; public int Marks; } Question: How can I avoid hardcoding the property name,

how to read data from csv file into C# console Application

∥☆過路亽.° 提交于 2020-01-07 04:22:48
问题 using System; namespace jagged_array { class Program { static void Main(string[] args) { string[][] Members = new string[10][]{ new string[]{"amit","amit@gmail.com", "9999999999"}, new string[]{"chandu","chandu@gmail.com","8888888888"}, new string[]{"naveen","naveen@gmail.com", "7777777777"}, new string[]{"ramu","ramu@gmail.com", "6666666666"}, new string[]{"durga","durga@gmail.com", "5555555555"}, new string[]{"sagar","sagar@gmail.com", "4444444444"}, new string[]{"yadav","yadav@gmail.com",

how to read data from csv file into C# console Application

吃可爱长大的小学妹 提交于 2020-01-07 04:22:27
问题 using System; namespace jagged_array { class Program { static void Main(string[] args) { string[][] Members = new string[10][]{ new string[]{"amit","amit@gmail.com", "9999999999"}, new string[]{"chandu","chandu@gmail.com","8888888888"}, new string[]{"naveen","naveen@gmail.com", "7777777777"}, new string[]{"ramu","ramu@gmail.com", "6666666666"}, new string[]{"durga","durga@gmail.com", "5555555555"}, new string[]{"sagar","sagar@gmail.com", "4444444444"}, new string[]{"yadav","yadav@gmail.com",

Selected item not displayed in the DataGridComboBoxColumn

谁说我不能喝 提交于 2020-01-07 04:16:05
问题 I have a DataGrid with two DataGridComboBoxColumn s set in the XAML (copied from here): <DataGrid x:Name="joinGrid" AutoGenerateColumns="False" CanUserAddRows="True"> <DataGrid.Columns> <DataGridComboBoxColumn> <DataGridComboBoxColumn.ElementStyle> <Style TargetType="ComboBox"> <Setter Property="IsDropDownOpen" Value="True" /> <Setter Property="ItemsSource" Value="{Binding Path=TableAColumns}" /> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{Binding}"><

Any good async workflow patterns for C# 4?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-07 04:08:33
问题 Can anyone point me to some patterns for handling async workflows in C#? I know this is coming soon in C# 5 but I was wondering if anyone had already done an implementation in C# 4 that approximates the same effects? Basically I'm writing a lot of async code in Silverlight 4 like this: CallService( (service) => service.DoSomething(1, 2, 3), (response) => { // some local code // need to call another service async CallService( (service) => service.DoSomethingElse(4, 5, 6), (response) => { //

Need iText7 HTML to PDF Encryption Code in C#

强颜欢笑 提交于 2020-01-07 03:48:58
问题 I Have Installed iText7 trail Version Packages to convert html file into pdf. I have succefully converted html to pdf using proper code like they(iText Software) mentioned.But still i am not clear to set the Password for created pdf. After converting html file to pdf,the pdf file should be protected with password.so please anyone help me what is the code in c# to encrypt the pdf file while converting from html. 回答1: You didn't share any code (which is actually a requirement when you post a

WSE 3.0 creates the UsernameToken but Username and Password values are empty

筅森魡賤 提交于 2020-01-07 02:58:24
问题 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">

OrientDB automatic on-record changelog via trigger

吃可爱长大的小学妹 提交于 2020-01-07 02:54:49
问题 long time lurker but first question. Finally figured out how to maintain a changelog by trigger on this question Embedding record from function in OrientDB But I'd also like to maintain the user updating the record, and maybe other metadata like which props were updated. My use case is passing batches of upserts from c# using HTTP requests with a JSON array of commands, into some base classes as follows: ALTER CLASS V SUPERCLASS +OTriggered CREATE CLASS ChangeHistory ABSTRACT CREATE PROPERTY