473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Conditional attribute no longer allows out parameters?

Upgraded to .NET 2.0 and VS.NET'05 and while compiling code that was
fine under 1.1/2003 I'm getting a fatal compiler error:

Conditional member 'GetTraceMode(out System.Web.TraceMode)' cannot have
an out parameter

and here's the method:

[Conditional("TRACE")]
public static void GetTraceMode(out TraceMode mode)
{
mode = TraceMode.Default;
HttpContext context = HttpContext.Current;
if (context != null)
mode = context.Trace.TraceMode;
}

I have to assume this is by design in C# 2.0, but what's the rationale?
I can't find anything about this in the C# language reference.

Thanks.

-glenn-

Nov 17 '05 #1
2 3188

"GlennDoten" <gd****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Upgraded to .NET 2.0 and VS.NET'05 and while compiling code that was
fine under 1.1/2003 I'm getting a fatal compiler error:

Conditional member 'GetTraceMode(out System.Web.TraceMode)' cannot have
an out parameter

and here's the method:

[Conditional("TRACE")]
public static void GetTraceMode(out TraceMode mode)
{
mode = TraceMode.Default;
HttpContext context = HttpContext.Current;
if (context != null)
mode = context.Trace.TraceMode;
}

I have to assume this is by design in C# 2.0, but what's the rationale?
I can't find anything about this in the C# language reference.


The rationale is pretty simple. An out parameter affects a variable in the
calling method, thus the method affects your methods state and when its not
compiled in on a build changes the way the method works. You'll note that
return values were not allowed on 1.1. I'd guess out parameters were a bit
of an oversight in the first spec.
Nov 17 '05 #2
Yeah, that makes sense. I suppose I was getting around the requirement
that a conditional method always return void by using the out
parameter. You're guess that allowing out parameters previous to 2.0
was an oversight makes sense to me.

-glenn-

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: web developer | last post by:
hi I need to write a stored procedure that takes input parameters,and according to these parameters the retrieved fields in a select statement are chosen. what i need to know is how to make the...
28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
10
by: John Smith | last post by:
After reading C# documentation the Conditional attribute seemed the way to go, but after inspecting the IL it seems those methods are still there and I imagine the CLR removes them. Using #if DEBUG...
3
by: Kumar | last post by:
Hi Folks, I have a question regarding conditional hyperlink in datagrid. I want to display Hyperlink if my QID values in (1,4,5,6) other wise i want to display just Qdescription with out...
4
by: kj | last post by:
I have a dynamically generated HTML document that includes a table of numbers. In this table, I want every number greater than some numerical parameter MAX_VAL (also dynamically generated) to be...
1
by: Marek | last post by:
I use VS2005 with framework 2.0 and I just found a behavior I consider odd. Here is the code that illustrates th eproblem: public static void MethodA() { MethodB() } #if DEBUG
6
by: Jared | last post by:
Consider the following two functionally identical example queries: Query 1: DECLARE @Name VARCHAR(32) SET @Name = 'Bob' SELECT * FROM Employees WHERE = CASE WHEN @Name IS NULL THEN ELSE...
7
by: Frank Munsberg | last post by:
Hi There, I'm currently in a mild state of confusion about the Conditional Attribute. The code below is taken from the implementation of "Design By Contract" that I've put in somewhere in my...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.