473,799 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is this c# syntax?

hi
I'm new to c# and although having read 2 tutorials I cannot find what the
parenthesis in these 2 example situations mean;

1) string strKeyValue = (string)sampleC onfig["Title"];
2) class myParentPage = (default_aspx) this.Page;

(default_aspx is the class name for my parent Page)
Nov 16 '05
11 1722
Roy,

Well then perhaps I should rephrase it this way:

"To successfully cast any reference type A to B, A and B must either have an
inheritance relationship with one another, or A must have an appropriate
user-defined type conversion operator defined for type B."

Thanks for the nice refinement.

--Bob

"Roy Fine" <rl****@twt.obf uscate.net> wrote in message
news:ea******** ******@TK2MSFTN GP11.phx.gbl...

"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Simple value types have conversion rules that are defined by the C#

language
specification.

To successfully cast any reference type A to B, A and B must have an
inheritance relationship with one another.


not exactly true - what about the implicit conversion operator.

Consider the following in which there is absolutely no inheritance
relationship between MyString and YourString - yet the cast works as
defined
:

regards
roy fine
/* *************** *** */
public void Test(){
YourString a = new YourString("goo dbye");
MyString b = (MyString)a;
}

/* *************** *** */
class MyString{
string val;
public MyString(string t){val=t;}
}

/* *************** *** */
class YourString{
string val;
public YourString(stri ng t){val=t;}
public static implicit operator MyString (YourString t){
return new MyString("Hello ");
}
}

Nov 16 '05 #11
bob, well done.

rlf

"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
Roy,

Well then perhaps I should rephrase it this way:

"To successfully cast any reference type A to B, A and B must either have an inheritance relationship with one another, or A must have an appropriate
user-defined type conversion operator defined for type B."

Thanks for the nice refinement.

--Bob

"Roy Fine" <rl****@twt.obf uscate.net> wrote in message
news:ea******** ******@TK2MSFTN GP11.phx.gbl...

"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Simple value types have conversion rules that are defined by the C#

language
specification.

To successfully cast any reference type A to B, A and B must have an
inheritance relationship with one another.


not exactly true - what about the implicit conversion operator.

Consider the following in which there is absolutely no inheritance
relationship between MyString and YourString - yet the cast works as
defined
:

regards
roy fine
/* *************** *** */
public void Test(){
YourString a = new YourString("goo dbye");
MyString b = (MyString)a;
}

/* *************** *** */
class MyString{
string val;
public MyString(string t){val=t;}
}

/* *************** *** */
class YourString{
string val;
public YourString(stri ng t){val=t;}
public static implicit operator MyString (YourString t){
return new MyString("Hello ");
}
}


Nov 16 '05 #12

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

Similar topics

28
3310
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are a number of aspects to this simplification, but for me the unification of methods and functions is the biggest benefit. All methods look like functions (which students already understand). Prototypes (classes) look like modules. This will...
37
2610
by: Bengt Richter | last post by:
ISTM that @limited_expression_producing_function @another def func(): pass is syntactic sugar for creating a hidden list of functions. (Using '|' in place of '@' doesn't change the picture much (except for people whose tools depend on '@' ;-)). I.e., (not having the source or time to delve) the apparent semantics of the above is something roughly like
70
8916
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this expression should equal to "sizeof( (int)(*p) )", but the compiler does NOT think so. Why? Can anyone help me? Thanks. Best regards. Roy
121
10186
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
8
4052
by: Hermawih | last post by:
Hello , I want your opinion about this . In order to say it clearly , I think I have to describe it in long sentences . I could consider myself as Intermediate/Advance Access Developer ; Intermediate/Advanced Database designer . Because of the requirements , I must create Web Application . Access Pages is not suitable for that so I think about learning VB Net / ASP Net . I am
6
407
by: Daniel Rudy | last post by:
What is wrong with this program? When I try to compile it, I get the following error. Compiler is gcc on FreeBSD. strata:/home/dcrudy/c 1055 $$$ ->cc -g -oe6-3 e6-3.c e6-3.c: In function `main': e6-3.c:32: syntax error before `||' e6-3.c:33: syntax error before `printf' e6-3.c:36: syntax error before `||' e6-3.c:40: syntax error before `(' e6-3.c:40: syntax error before `strcpy'
10
3237
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
3
16253
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very strange error. In your experience, where I should looking to find the real error? Surely the sintax of glut is correct... gcc.exe -c glut_bitmap.c -o glut_bitmap.o -I"C:/Dev-Cpp/include" -I"../../include" -D__GNUWIN32__ -W -DWIN32 -DNDEBUG...
5
2388
by: Cylix | last post by:
this.menus = { root: new Array };
14
9859
by: gimme_this_gimme_that | last post by:
What is going on here with the dollar signs and parenthesis? $(document).ready(function(){ $("li").behavior("click",function(){ $(this).load(menu.html"); }); }); And when do you use click vs. onclick? Is onclick only an attribute thing?
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.