Operators - <> And Not - Write Standards Documentation ?
Mar 16, 2009
I'm having the exciting task of finding out about VB.NET's <> and Not operators. Not - I'm assuming by my small use of it - is the functional equivalent of ! in languages such as C# and <> being equivalent of !=.
In VB.NET a common problem is doing Boolean expressions against objects that don't have a reference, it appears. So if we do If Request.QueryString("MyQueryString") <> Nothing Then This will actually fail if the query string doesn't exist. Why, I don't know. The way that it's done by older coders is as follows: If Not Request.QueryString("MyQueryString") Is Nothing Then
And this tends to work. To me they're functionally equivalent though operators tend to do different comparisons dependent on certain factors such as operator precedence, why it doesn't work in this case however, I do not know, and neither have I found any relevant material. I ask this as I'm having to write standards documentation and we're determining the use of either the Not or <>.
I recently installed visual studio 2010 and am using visual basic.The problem I am having is that some operators do not show up within the editor. For example the code line below test = 3 + 5 - 6 / 7 * 4
only displays
test 3 5 - 6 / 7 * 4
the = + operators are not visible although they are there since the program will work as intended....and if I open up the .vb file in notepad everything is there. It just won't display within Visual Studio.
Possible Duplicate: C# Coding standard / Best practices
What VB.NET or C# coding standards are you using for your .NET applications?I was looking at hungarian notation and I don't think it is a good idea for a .NET application.
I have the following controller actions: <HttpGet()> Function News() As ActionResult End Function <HttpGet()> Function News(ByVal id As Integer) As ActionResult End Function
I want it to be smart, and go to the first if I have no ID in the url, and the second if there is. I got the following error: The current request for action 'News' on controller type 'MarketsController' is ambiguous >between the following action methods: System.Web.Mvc.ActionResult News() on type TradeChaseMVC.MarketsController System.Web.Mvc.ActionResult News(Int32) on type TradeChaseMVC.MarketsController
So, I thought if i explicitly created routes without the id parameter optional, like this: routes.MapRoute( _ "Default2", _ "{controller}/{action}/{id}", New With {.controller = "Home", .action = "Index"}, New With {.action = "^[a-zA-Z_]+$", .id = "d{1,8}|"} [Code] .....
It would work, but it doesn't same error. Now I know the simple solution is to call my methods different things, but i don't want to do this. I was also thinking of creating an attribute to prefix the ID method, to check for ID being there, and if it isn't dont allow that method, but I can't get this to work either.
have a form that is used to enter employee information and I also have a class object that I use to validate data and pass employee information around. What are the proper names for the form and the class?
What international organisations exist for agreeing a standard or standards for communications, file formats and so forth?I know for instance you can apply to a company like.>>URL}..to get a barcode.
For more see.>> http://www.google.co.uk/#hl=en&source=hp&q=how+do+you+get+a+barcode&fp=9b029eaa092cce63
I want to place the arithmetic operators in an array so I can randomly select one at a time. I am not sure how to declare and initialize them so that I can use them in an equation.
Did anyone else read this article under Visual Basic News? I thought it was a very bad treatment of the subject. I especially don't like articles like that when the code they post relies on Option Strict Off.
As a learning experience I decided to try and implement the Shunting Yard Algorithm(string calculator) using OOP. It was successful for as far as I took it, but it had one flaw. In order to get the stack to be accessible from the operators I had to declare it as shared, which meant that all versions of the calculator shared one stack. This very short piece of code illustrates what I came up with and the "flaw". [code] How can I maintain the functionality of anOP.add1 without declaring "something" as shared?
According to MSDN The And operator can act as a bitwise operator OR a logical operator.The only way to know if it is used as One operator or another is, If it is on the right side of an assignment operation? for example x = 3 AND 5. I cannot find any other instances where the bitwise operator would be used instead of the logical operator, are there?
Can I store the common operators such as '>', '<', '+' etc., in a variable and then use it when required.
[Code]....
so here instead of directly using > and +, Can I use the variables OP1 and OP2 somehow. May be I can put the entire string from "If..... NUM1" in another variable as text string and then execute that variable.
Using 2 objects of the same type, I'm trying to implement < and >, but I can't seem to find any authoritative source on what to do with either or both being Nothing. In other words what the accepted practice or MSDN suggestions are.[code]Accessors is my canonical method for centralizing an enumeration of the properties (all are decimal)return false for both if either is Nothing?I found a comment, but can't seem to verify or validate it that A null object is always less than a non-null object..
I have a weird situation. I have a C++ code that overloads the +,-,* operators and exports them in a .DLL file. Now, I want to import those overloaded operators from within VB.NET code. So it should be like this:
<DllImport("StructDLL.dll")> Public Shared Function Operator +(ByVal a1 As A, ByVal a2 As A) As A End Function
So what I'm trying to do above it just import the lovely overloaded operator + from the DLL.Note that the operator is already overloaded from inside the DLL, so should I import it as a Function or as an Operator like this?
<DllImport("StructDLL.dll")> Public Shared Operator +(ByVal a1 As A, ByVal a2 As A) As A End Operator
The overloaded plus operator is supposed to add structs. So the DLL is programmed to work on structs (C++) and I want to import it in VB.NET to work on Structures.
I have a custom class that simply contains a public variable X.Let's say I have two instances of the class, A and B.If I execute an assignment operator, such as:A = B then I want A.X equal to the VALUE of B.X.But, I'm pretty sure that this will just assign B to the variable A.Assigning pointers, in C++ lingo.I looked in the VB.NET docs, which state that "The operator can be overloaded only as a relational comparison operator, not as an assignment operator."
In C# you can use the implicit keyword to define an implicit user-defined type conversion operator.In VB.NET you can define a CType conversion operator that will explicitly convert a user-defined type into another type.Is there a way to declare an implicit conversion operator in VB.NET?
I have to perform calculations dynamically in ASP/VB.NET (Possibly SQL Server). Something like this: Dim var1, var2 as Integer Dim Optr as string var1 = 15 var2 = 25 Optr = + MyResult(var1, var2, Optr) And MyResult should equal 40. How can I do this?
I have a class that implements an interface. Other objects will get an instance via a method like:
Dim AU1 as IAUC = GetAU(<some GUID>) Dim AU2 as IAUC = GetAU(<some other GUID>)
What I would like to be able to do is this:If AU1 = AU2..The parts of the class that make up the interface could be equal when the rest of the class is not, and the equality of the interface objects (if you can call them that) is complicated. Several fields have to be compared in odd ways.One option I have is to just add an Equality method to the interface, which would work, but I would rather overload the = and <> operators. As far as I can see, you cannot overload operators as part of an interface, but I was hoping that I had overlooked something.
I have a simple routine to find the next object based on a name property in an un-ordered collection of objects. I go through the collection and collect all the names in a List(of String) adding any names that are > my current name, which should give a list of everything that comes after the current key. I then sort the list using the default .Sort() method on the List(of String) and take the first item in the list, which should be my next item. I do the reverse to find the previous item, add all items < my current name, sort, and take the last item in the list.
However, this method skips over some items. For example I have items named 1210, 1210-ADA, and 1210_ADA_DB. Using this method, getting the next item skips the middle item 1210-ADA and finds 1210_ADA_DB, but finding the previous item seems to work.
Given that a typical coding mantra is "Don't induce side effects in method calls." and that the only reason (that I know off - please enlighten me if I'm wrong) to not use short circuited operators is when you depend on the side effects of a method call in subsequent code. Why isn't the default operator in languages like C# and VB.NET not a short circuited version?
Of the 51 Standard Query Operators (of which only 42 are actually query operators), only 24 are directly supported by Visual Basic 9 and just 11 by C# 3: Query Expression Syntax for Standard Query Operators.In many cases, query syntax is arguably more readable than the equivalent method syntax, especially when transparent identifiers are involved. However, that readability breaks down if you have to combine queries and method calls.So the question: What query operators, current or hypothetical, would you like to have your language of choice support in query expression syntax?