You searched for new guid. We found 22 results in 0.305 seconds.

Creating a Guid > conversion from VB to C#

I have the following code in VB.Net and I'm trying to convert it to C#. listContacts = ACT_FRAMEWORK.Contacts.GetContactsByID(Nothing, New Guid() {New Guid(ContactID)}) Below...
Jon Skeet
people
quotationmark

Guid.NewGuid is a method, and you're not calling that method from your VB code - you're calling the constructor accepting a string. You can call that same constructor in C#: // Using an array initializer for simplicity Guid[] test = { new... more

people

Convert GUID to string Entity Framework

At the risk of asking a duplicate question, I cannot seem to get this to work. There are many examples of what I want to do but the syntax isnt quite the same and nothing has...
Jon Skeet
people
quotationmark

You want AsEnumerable() to force the ToString() call to be evaluated locally rather than as part of the EF query. For example: using (DBEntities de = new DBEntities()) { string[] roleset = de.MySQLView ... more

people

Convert IDictionary<Guid,string> to the IEnumerable<SelectListItem>

How i can convert IDictionary<Guid,string> to the IEnumerable<SelectListItem>? I want to use string as SelectListItem.
Jon Skeet
people
quotationmark

Well you could just use dictionary.Values().Select(x => new SelectedListItem { Text = x }) Just be aware that it may not be in a useful order: Dictionary<,> is inherently unordered (or rather, the order may change and... more

people

Why are there memory allocations when calling a func

I have the following program which construct a local Func from two static methods. But strangely, when I profile the program, it allocated close to a million Func objects. Why...
Jon Skeet
people
quotationmark

You're using a method group conversion to create the Func<long, long, bool> used for the comparerFunc parameter. Unfortunately, the C# 5 specification currently requires that to create a new delegate instance each time it's run. From... more

people

Adding Count of Arrays Together returns 0

I have the following class, where the arrays are populated public class InternalTag_RelatedObjectsViewModel { public Guid[] BranchIDS { get; set; } public Guid[]...
Jon Skeet
people
quotationmark

You're missing precedence, basically. It's easier to see what's going on when this is reduced to a minimal example: using System; public class Program { public static void Main() { string[] a = { "x", "y" }; ... more

people

Get List<Guid> from object C#

I have function GetChildren, which returns all the child nodes, in a structure as they need to be in treeview. public static object GetChildrenNodes(IEnumerable<NodeDto>...
Jon Skeet
people
quotationmark

I would avoid using the same method. You've got two different requirements: Build a collection of anonymous types for use in the UI Build a list of GUIDs for children of the given node ID (I'm assuming you only want direct children,... more

people

Value and reference type in generic type implementation

I searched about generic type in C# and I made this conclusion: All reference types are based on Class All value types are based on struct The main differences between struct...
Jon Skeet
people
quotationmark

What you're describing are generic constraints. Where T:New() == the generic parameter must be a class + have a default empty constructor No, that just says "the type argument must have a parameterless constructor". That actually... more

people

XML Root Element Parsing

I am parsing an xml file using the following which works well but my question is how do I get the value from the tag <themename> because I am using oXmlNodeList for my loop....
Jon Skeet
people
quotationmark

I'd use LINQ to XML to start with. Something like this: var doc = XDocument.Load(...); var themeName = doc.Root.Element("themename").Value; Guid themeGuid = Guid.NewGuid(); foreach (var element in... more

people

check if record exists in database using LINQ

I am getting a cast error here but I do not understand as to why. protected bool isPlayerdb(string userName) { try { Users adminUsers = from users in...
Jon Skeet
people
quotationmark

You're asking to assign a sequence value to single entity variable. That's like trying to do this: // Won't work for the same reason string name = new List<string> { "foo", "bar" }; If you're just trying to find out whether there... more

people

How to avoid code duplication inside two methods?

I have two identical methods, but one of them have return statement inside try catch public void A(Guid agentId) { var agent = _agentsProvider.GetAgentById(agentId); ...
Jon Skeet
people
quotationmark

Unless GetPreviousCacheEntry could have problematic side-effects, it seems to me that you don't need method A at all. Just call method B and ignore the return value if you're not interested in it. As noted in comments, the methods aren't... more

people