c#-to-vb.net

How to insert values into VB.NET Dictionary on instantiation?

旧街凉风 提交于 2020-06-22 07:40:30
问题 Is there a way that I can insert values into a VB.NET Dictionary when I create it? I can, but don't want to, do dict.Add(int, "string") for each item. Basically, I want to do "How to insert values into C# Dictionary on instantiation?" with VB.NET. var dictionary = new Dictionary<int, string> { {0, "string"}, {1, "string2"}, {2, "string3"} }; 回答1: If using Visual Studio 2010 or later you should use the FROM keyword like this: Dim days = New Dictionary(Of Integer, String) From {{0, "string"},

Any VBNET equivalence of C# where generic constraint keyword?

人走茶凉 提交于 2020-02-27 15:09:05
问题 First, I wish to write myself a generic type for operations against the underlying Active Directory. For those of you who know about AD and the System.DirectoryServices namespace, the DirectoryEntry class is the top most important along with the DirectorySearcher class. When speaking the AD language, everything is a DirectoryEntry. With that said, my application needs to manage Users, Groups and Organizational Units (OU). Each of these objects are AD entries. Then, this sounds to me a good

Any VBNET equivalence of C# where generic constraint keyword?

自作多情 提交于 2020-02-27 15:08:21
问题 First, I wish to write myself a generic type for operations against the underlying Active Directory. For those of you who know about AD and the System.DirectoryServices namespace, the DirectoryEntry class is the top most important along with the DirectorySearcher class. When speaking the AD language, everything is a DirectoryEntry. With that said, my application needs to manage Users, Groups and Organizational Units (OU). Each of these objects are AD entries. Then, this sounds to me a good

Is there a VB.NET equivalent of C# out parameters?

元气小坏坏 提交于 2020-01-26 16:27:50
问题 Does VB.NET have a direct equivalent to C# out function parameters, where the variable passed into a function does not need to be initialised? 回答1: No, there is no equivalent of the out keyword in VB. However, VB does automatically initialise all local variables in a method, so you can use ByRef without needing to explicitly initialise the variable first. Example: Sub Main() Dim y As Integer Test(y) End Sub Sub Test(ByRef x As Integer) x = 42 End Sub (If you examine code in the framework (for

DataGridView Header Stacked - VB.NET

微笑、不失礼 提交于 2020-01-15 11:37:18
问题 I need the columns Headers to be Stacked, like Header Cells Merged. The Same as in this image. Please Refer to this link. It is done with C#. It does exactly what I need. http://www.codeproject.com/Articles/474418/DataGridViewplus-e2-80-93plusStackedplusHeader But the Problem is, Im working on vbproj and It cant include this C#. I used some code converters and ended with some errors in raising events, etc. Is there any way to get this in VB.NET Or Is there any other way to make this stacked

DataGridView Header Stacked - VB.NET

做~自己de王妃 提交于 2020-01-15 11:36:08
问题 I need the columns Headers to be Stacked, like Header Cells Merged. The Same as in this image. Please Refer to this link. It is done with C#. It does exactly what I need. http://www.codeproject.com/Articles/474418/DataGridViewplus-e2-80-93plusStackedplusHeader But the Problem is, Im working on vbproj and It cant include this C#. I used some code converters and ended with some errors in raising events, etc. Is there any way to get this in VB.NET Or Is there any other way to make this stacked

VB.NET: What is static T (C#) in VB.NET?

ε祈祈猫儿з 提交于 2020-01-03 11:33:37
问题 Consider: public static T GetValueOrDefault<T>(this IDataReader reader, string columnName) T returnValue = default(T); I want to implement something like this to check DBNull. I can follow the code fine, but I don't quite understand what static T is in VB.NET. Can someone please explain it a bit? 回答1: The equivalent of static in VB in Shared . Shared methods are usually put in Helper classes, because they do not require an instance of the class to run. The type T indicates that this is a

C# -->Go to Definition ==> VB.NET

时光总嘲笑我的痴心妄想 提交于 2019-12-31 02:46:26
问题 I have a solution in VS 2010. There are two DLL projects: one UserControl in C# WPF (myCSharpUC) and other - WinForm UserControl in VB.NET (myVbUC) Actually in myCSharpUC I have an instance of myVbUC: myCSharpUC { private MyVbUC vbControl; ... somemethod() { vbControl.MyProperty } } Is there a way to "navigate to definition" of MyProperty directly? ( actually only metadata is displayed ) 回答1: It's a known issue, the workaround are two: use ctrl+, or use some plugin that add this function,

Differences in LINQ syntax between VB.Net and C#

你离开我真会死。 提交于 2019-12-29 04:17:10
问题 Again, just out of curiosity: After I have programmed several projects in VB.Net I to my surprise discovered that there are some more than subtle differences between C# and VB.NET LINQ usage. For example, if we want to group elements by multiple properties (columns) we need to create a new anonymous type explicitly: var procs = from c in Process.GetProcesses() group c by new {c.BasePriority, c.Id} into d select d; whereas in VB.NET more straightforward syntax will already do: Dim b = From c

Need help translating C# to VB

余生长醉 提交于 2019-12-24 01:46:07
问题 I am looking at this blog, and I am trying to translate the snippet to VB. I'm having difficulties with this line: NotifyCollectionChangedEventHandler handlers = this.CollectionChanged; NOTE: CollectionChanged is an event of this ('this' is an override of ObservableCollection<T> ). 回答1: To raise the event, OnCollectionChanged should work fine. If you want to query it you have to get more abusive and use reflection (sorry, example is C# but should be virtually identical - I'm not using any