How to print Field name with value of a Class object?

hi, In C#, I need to print a class field or property name with value without using reflection or string.join method.
For eg.
protected void Button1_Click(object sender, EventArgs e)
List<EmployeeInfo> obj = new List<EmployeeInfo>();
obj.Add(new EmployeeInfo { eid = 123 });
obj.Add(new EmployeeInfo { ename = "abc" });
Response.Write(obj.ToString()); // output must be => ename ="abc" , eid = 123
public class EmployeeInfo
public string ename;
public int eid;
It need to be resulted as follows automatically with property name and value :
ename ="abc" , eid = 123
It need to be resulted with good performance and simple way.

You could override ToString method in EmployeeInfo class:
public class EmployeeInfo
public string ename;
public int eid;
public override string ToString()
return string.Format("ename =\"{0}\" , eid = \"{1}\"", ename, eid);
protected void Button1_Click(object sender, EventArgs e)
EmployeeInfo obj = new EmployeeInfo() { eid = 111, ename = "aaa" };
Response.Write(obj.ToString());

Similar Messages

  • Chart View( How to Stick a Name with Value)?

    Hi,
    How can we Stick a name with value in chart view.Please share with me if anybody have an idea.
    Thanks
    VVR
    Edited by: 806756 on Jun 10, 2011 7:24 AM

    Please help me on this.

  • How To Print Field Value in TOP-OF-PAGE During Line Selection.

    How To Print Field Value in TOP-OF-PAGE During Line Selection when double click on field.

    (If my memory serves me well (not used for long time ago)
    Assign values to system fields sy-tvar0 - sy-tvar9, they will replace the placeholders "&0" through "&9" in the list headers and column headers.
    TOP-OF-PAGE DURING LINE-SELECTION.
         WRITE: / 'Interactive Report &3'.
      WRITE record-vbeln TO sy-tvar3.
    Regards,
    Raymond

  • Field names with now values behind are written to RDI-File?

    Dear experts,
    I have a question concerning the RDI file format.
    The specification of RDI file said the following about the structure of each RDI file
    "field name" is placed in position                 :        104     
    "field length" indicator is placed in position :        235 - 237
    "field value" is placed in position                 :        241     Specified by u2018field length indicatoru2019
    In addition I got the information, that even if there is no field value for a specific field name. That the field name and also the length of the field will be displayed in the RDI file.
    Now I generated an RDI file and I see that only these field (name, position, value) are displayed in RDI which have a value. Fields which contains no value are not displayed!
    In conclusion, my first question would be if its correct that field names and also the lengths are everys time displayed in RDI even if there is no value for it?
    If this is true,  the second question would be: Whatr could be the reason that the field names are not in the RDI file when there is no value for it.
    Thanks in advance for any helpful answers

    Dear experts,
    I have a question concerning the RDI file format.
    The specification of RDI file said the following about the structure of each RDI file
    "field name" is placed in position                 :        104     
    "field length" indicator is placed in position :        235 - 237
    "field value" is placed in position                 :        241     Specified by u2018field length indicatoru2019
    In addition I got the information, that even if there is no field value for a specific field name. That the field name and also the length of the field will be displayed in the RDI file.
    Now I generated an RDI file and I see that only these field (name, position, value) are displayed in RDI which have a value. Fields which contains no value are not displayed!
    In conclusion, my first question would be if its correct that field names and also the lengths are everys time displayed in RDI even if there is no value for it?
    If this is true,  the second question would be: Whatr could be the reason that the field names are not in the RDI file when there is no value for it.
    Thanks in advance for any helpful answers

  • IF_IXML : How can i add encoding with value UTF-8 to the document object??

    Hi
    i want to create a xml file with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    i did this with the if_ixml interface and rendered the content in a file 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml
    <?xml version="1.0"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    BUT the document attribut(?) encoding="UTF-8"?> is missing!
    How can i add encoding with value UTF-8 to the document object?? it should look like:
    <?xml version="1.0" encoding="UTF-8"?>
    *here is my coding.
    TYPE-POOLS: ixml.
    CLASS cl_ixml DEFINITION LOAD.
    DATA: lo_ixml           TYPE REF TO if_ixml,
          lo_streamfactory  TYPE REF TO if_ixml_stream_factory,
          lo_document       TYPE REF TO if_ixml_document,
          lo_parent         TYPE REF TO if_ixml_element,
          lo_ostream        TYPE REF TO if_ixml_ostream,
          lo_renderer       TYPE REF TO if_ixml_renderer,
         lv_rc           TYPE i.
    lo_ixml = cl_ixml=>create( ).
    lo_streamfactory = lo_ixml->create_stream_factory( ).
    lo_document = lo_ixml->create_document( ).
    lo_parent = lo_document->create_simple_element( name   = 'OpenSearchDescription'  "root node
                                                    parent = lo_document ).
    lo_parent->set_attribute_ns( name   =  'xmlns'
                                 value  = 'http://....' ).
    *rausrendern in file
    lo_ostream = lo_streamfactory->create_ostream_uri( system_id = 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml' ).
    lo_renderer = lo_ixml->create_renderer( ostream  = lo_ostream
                                            document = lo_document ).
    lv_rc = lo_renderer->render( ).
    Thanks for help
    Britta

    Use the following code:
    set an document encoding
      l_encoding = l_ixml->create_encoding( character_set = 'UTF-8'
                                            byte_order = if_ixml_encoding=>co_none ).
      l_success  = l_ostream->set_encoding( encoding = l_encoding ).
    create a xml renderer
      l_renderer = l_ixml->create_renderer( document = l_doc ostream  = l_ostream ).

  • Flat file should have source field name and value

    Hi Friends
    I have a scenario of Idoc to Flat file , where in the target structure the field name and value should be present, generally only the value is available in a flat file.The target structure is as below:
    for e.g RECTYPE is the Field Name and A is the value.
    RECTYPE,A
    DATEH,20111101
    TIMEH,173125
    RECTYPE,B
    ORDNUM,4500054536
    ORDITM,150
    SUPDAT,20090218
    PLNQTY,000000006
    MATNR,14B300
    BATCH,5697
    PLANT,3026
    DELIVTYPE,PO
    SUPPLIER,0000023305
    SUPNAME,Deutsche BP AG
    SUPADRS,Erkelenzer Strasse 20
    SUPCITY,Monchengladbach
    SUPPOST,41179
    SUPCOUN,DE
    TRUCK_NBR,7589
    BOND_FLG,X
    STG_LOC,PLCL
    LINE_ACTION,CRE
    RECTYPE,B
    ORDNUM,4500056721
    ORDITM,10
    SUPDAT,20090218
    PLNQTY,000000013
    MATNR,116703
    BATCH,6589
    PLANT,3026
    DELIVTYPE,PO
    SUPPLIER,0000023380
    SUPNAME,DOW Belgium NV
    SUPADRS,Havenlaan 7
    SUPCITY,Tessenderlo
    SUPPOST,3980
    SUPCOUN,BE
    TRUCK_NBR,7589
    BOND_FLG,X
    STG_LOC,PLCL
    LINE_ACTION,CHG
    RECTYPE,X
    DATEH,20111101
    TIMEH,173125
    RECORDS,3

    Hi,
         NameA.addHeaderLine
    Specify whether the text file will have a header line with column names. The following values are permitted:
    ■       0 u2013 No header line
    ■       1 u2013 Header line with column names from the XML document
    ■       2 u2013 As for 1, followed by a blank line
    ■       3 u2013 Header line is stored as NameA.headerLine in the configuration and is applied
    ■       4 u2013 As for 3, followed by a blank line
    This specification is only permitted if exactly one structure is defined.
    regards,
    ganesh.

  • How to print a string with out using main method??

    how to print a string with out using main method??
    if we can tell me with example?
    thanks in adavance
    raja

    Hi,
    actually there's none. The UITableView class needs to "know" the tableView's height so either it can calc <number of rows> times <row height> or it has to sum the height of each single row.
    If the row which needs to be of different size always is the first or the last row you can user a tableHeader or tableFoot view.
    Regards
    Dirk

  • How to print interest along with dunning letter

    HI  guys  plz
    How to print interest along with dunning letter
    Many thanks to you
    Raju

    Hi,
    ABAP development is required for your requirement. Ask your abaper to develop the programme to print dunning letter along with interest
    Regards,
    Satish Muvva.

  • How to find index name with primarykey and column on a table?

    Hi,
    how to find index name with primarykey and column on a table?
    please help me.
    Thankyou.

      1  select ac.table_name, ac.index_name, aic.column_name
      2  from user_constraints ac, user_ind_columns aic
      3  where ac.constraint_type = 'P'
      4   and  ac.index_name = aic.index_name
      5* order by 1,2,3
    SQL> /
    TABLE_NAME                 INDEX_NAME                COLUMN_NAME
    ACTION_TABLE                 SYS_C0011033                NESTED_TABLE_ID
    ACTION_TABLE                 SYS_C0011033                SYS_NC_ARRAY_INDEX$
    CATEGORIES_TAB                 SYS_C0011038                CATEGORY_ID
    CUSTOMERS                 CUSTOMERS_PK                CUSTOMER_ID
    INVENTORIES                 INVENTORY_IX                PRODUCT_ID
    INVENTORIES                 INVENTORY_IX                WAREHOUSE_ID
    LINEITEM_TABLE                 SYS_C0011034                NESTED_TABLE_ID
    LINEITEM_TABLE                 SYS_C0011034                SYS_NC_ARRAY_INDEX$
    ORDERS                      ORDER_PK                 ORDER_ID
    ORDER_ITEMS                 ORDER_ITEMS_PK                LINE_ITEM_ID
    ORDER_ITEMS                 ORDER_ITEMS_PK                ORDER_ID
    PRODUCT_DESCRIPTIONS            PRD_DESC_PK                LANGUAGE_ID
    PRODUCT_DESCRIPTIONS            PRD_DESC_PK                PRODUCT_ID
    PRODUCT_INFORMATION            PRODUCT_INFORMATION_PK           PRODUCT_ID
    PROMOTIONS                 PROMO_ID_PK                PROMO_ID
    WAREHOUSES                 WAREHOUSES_PK                WAREHOUSE_ID
    16 rows selected.

  • How can i have a refrence of a java class object instance in my c++ project

    Hi!
    How can i have a refrence of a java class object instance in my c++ project. Is there a way?

    hahaxia wrote:
    The second question is the big one. The first question is half of the problem of "c++ to java" invocation and access. But the other half which is "java to c++ " invocation and access is still not solved. jni only provide the "java to c++ " DLL invocation Wrong,
    Using JNI your java classes can have methods implemented in C/C++.
    Using JNI you can call java classes.
    There is no other possible interaction between C++ and java, so it does it all.

  • How to change the print queue name with Lexmark printer?

    Is it at all possible to change the print queue name from Lexmark_3500_4500_Series, to something shorter? I try to link printouts from an old Sun Unix system, thru my iMac to the Lexmark X4580 multifunction printer. However, the Sun/Unix will not accept this long print queue name...

    Apologies, I misread. The only way I know of changing the Print Queue Name is by readding the printer.
     > System Preferences > Print & Scan > Add
    Choose your printer, make sure you change the print queue name to something different (equates to the Printer Name).
    When you need to print, simply select the printer you just added.
    Once your happy it works, delete the old printer from the list in Print & Scan.
    Morgan

  • How to view field name for a field in Oracle form?

    I was told you can do this but I forgot how.
    If you want to build a report, but don't know what the field name is in Oracle, you can open up the Oracle form and find the screen with that field name and do a trick that tells you the Oracle field name. Any help?

    Try this....
    REPORT ZZDYNAMIC_FIELD.
    DATA: BEGIN OF it1 OCCURS 0,
    printer(10) TYPE c,
    paper1(20) TYPE c,
    paper2(20) TYPE c,
    paper3(20) TYPE c,
    END OF it1.
    DATA: descr_ref TYPE REF TO cl_abap_tabledescr,
          i         TYPE i.
    FIELD-SYMBOLS:
      <key_comp_wa> TYPE abap_keydescr,
      <field>       TYPE ANY.
    it1-printer = 'MUC123'.
    it1-paper1 = 'KBLOGO'.
    it1-paper2 = 'BLANK'.
    it1-paper3 = 'DINA5'.
    APPEND it1.
    it1-printer = 'MUC123'.
    it1-paper3 = 'KBLOGO'.
    it1-paper2 = 'BLANK'.
    it1-paper1 = 'DINA5'.
    APPEND it1.
    TRY.
        descr_ref ?= cl_abap_typedescr=>describe_by_data( it1[] ).
      CATCH cx_root.
    ENDTRY.
    LOOP AT it1.
      i = 0.
      WHILE 1 = 1.
        i = i + 1.
        ASSIGN COMPONENT i OF STRUCTURE it1 TO <field>.
        if <field> is not assigned.
          EXIT.
        endif..
        IF <field> IS ASSIGNED AND <field> EQ 'KBLOGO'.
          READ TABLE descr_ref->key INDEX i ASSIGNING <key_comp_wa>.
          WRITE <key_comp_wa>-name.
          exit.
        ENDIF.
      ENDWHILE.

  • Field names with spaces in target file using fcc

    Hello Friends,
    My target structure fields:
    MT_Target
    ItemNo, ItemName, ItemQuantity, AmountValue, TotalAmount
    My requirement here is - In the target file - these fields should be generated with space. Shown as below:
    Item No, Item Name, Item Quantity, Amount Value, Total Amount
    How can i achieve this.
    Thanx
    S.

    if i understood u correctly u want to have a header line in ut target file same as that ur field names but with a space in between??
    if yes  the use :
    NameA.addHeaderLine=3
    NameA.headerLine =Item No, Item Name, Item Quantity, Amount Value, Total Amount
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm

  • Dynamic form... field names and values...

    Boy-Howdy. I wish I had the opportunity to stop by this forum and hang out at a time when I am not having issue, but, alas... I appreciate the brain power of the great minds that populate this forum.
    I have an issue: I think I am close on this but cannot identify where my syntax is going awry. Here is a simplified edition of my situation.
    I have a form with a set of dropdown menus that filter a recordset. The group of drop downs are dynamic from a database and will vary depending on what category of products a visitor is viewing.
    If I browse to FRUIT: I get three options that let me filter for:
    Fruit Type
    - Apples
    - Bananas
    - Pears
    Fruit Grown By:
    - Organic
    - Any
    Fruit From:
    - Domestic
    - South America
    - European
    However, if I browse to LUMBER I get:
    Wood Type:
    - Pine
    - Walnut
    - Oak
    Wood Prep:
    - Pre Cut
    - RAW Timber
    Wood Origin:
    - North America
    - South America
    - Europe
    I have the variable naming and database values worked out. My only issue is when I browse to friuit and select apples I want apples to remain selected as I page through results.
    So, the dropdown field names are dynamic. Currently set to zgen1, zgen2, zgen3. I set a variable named sr and increment it to build the progressive 1,2,3 after the field name zgen.
    <cfparam name="sr" default="1">
    <cfoutput group="ft_id" query="oompa2">
    <strong>#f_ftrname#:</strong><br>
    <select name="zgen#variables.sr#">
    <OPTION value="">select...</OPTION>
    <cfoutput>
    <OPTION value="#ft_id#_#fs_id#">#ft_options#</OPTION>
    </cfoutput>
    </select>
    <br><br>
    <cfset sr=#sr# + 1>
    </cfoutput>
    But when zgen1 has a value (in this case "Apples") I can't figure out how to dynamically test for the presence of a value for each dropdown. I have dynamically created the field names (cfset xvalue="FORM.zgen#variables.sr#") to test against. However this creates a value of FORM.zgen1, FORM.zgen2, FORM.zgen3 as it loops when I want it to be Apples, Organic, Domestic.
    Example:
    The code:
    <OPTION value="#ft_id#_#fs_id#"<cfif xvalue IS "#ft_id#_#fs_id#"> SELECTED</cfif>>#ft_options#</OPTION>
    which is translating to:
    <OPTION value="15_5"<cfif FORM.zgen1 IS "15_5"> SELECTED</cfif>>Apples</OPTION>
    When I want it to be:
    <OPTION value="15_5"<cfif 15_5 IS "15_5"> SELECTED</cfif>>Apples</OPTION>
    I hope I am making sense. I would greatly appreciate it if someone could help me noodle this. I have a feeling it is not as complicated as my mind is trying to make it. Thoughts?

    Three selects related type code was not the way to go - because I need each filter to be independent. I created a custom tag that argues the state for each separately up to ten filters.

  • How to find Field Name and Table Name

    Hi All,
    I got some output values from the legacy system with me but need to know whats the actual field name and table name to which i need to transfer these values. How can i do it, since which theres is not field name or despcription given for the data.
    Is there any way i can do it.
    Points will be rewarded for all useful answers.
    Regards
    AB

    Hi All,
    I got some output values from the legacy system with me but need to know whats the actual field name and table name to which i need to transfer these values. How can i do it, since which theres is not field name or despcription given for the data.
    Is there any way i can do it.
    Points will be rewarded for all useful answers.
    Regards
    AB
    Hi Abuser,
            now u have legacy data. now u want to do upload this data from legacy to r/3 by using one sap transaction. yes ok na..
      first of all u want to know the data is relevant to the which transaction...
       without knowing the transaction u cant trasfer the data..
    then open transaction put cursor on i/p field and click on f1
    and find out the field name & table..
    this is one method to find the field name and table name.

Maybe you are looking for

  • Nano no longer recognized by Windows

    I have a first generation Nano. It was connecting to Windows XP machine just fine and iTunes worked great --- until yesterday. Now it's no longer seen by iTunes, or by My Computer. I've reset the iPod and tried everything else on the support site. I

  • Shockwave player compatible with OSX 10.10.2?

    Since updating to Yosemite, I am having probs with shockwave player. When on certain sites, i get the error "plugin failed." I have reinstalled adobe reader to the latest version, and when checking shockwave it says i have most current version. I hav

  • What are the best settings to use for the newest AirPort Extreme (AC wifi) with my optimum online service provider?

    I have the current generation of the AirPort Extreme and a handful of devices that utilize the new 5Ghz A/C frequency. My internet speeds were blazing fast when I had first set it up but lately it has been lagging terribly. I was told that changing m

  • Score mode

    In score mood the default score-quantize setting keeps being wrong. I can change the default but when I start logic again the setting is gone. Can anybody help my with this?

  • Order of coordinates is affecting the SDO_AREA and SDO_LENGTH calculations

    I have done up a simple test using a 4 point polygon The first starts at (-122.526191446744, 37.8106779688415) index 0 The second starts at (122.518547789324, 37.8149407777871) index 1 Note even on this tiny example the results a slightly different R