Search Results

Search found 4638 results on 186 pages for 'john klinke'.

Page 9/186 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Tab Sweep: Primefaces3, @DataSourceDefinition, JPA Extensions, EclipseLink, Typed Query, Ajax, ...

    - by arungupta
    Recent Tips and News on Java, Java EE 6, GlassFish & more : • JSF2 + Primefaces3 + EJB3 & JPA2 Integration Project (@henk53) • The state of @DataSourceDefinition in Java EE (@henk53) • Java Persistence API (JPA) Extensions Reference for EclipseLink (EclipseLink) • JavaFX 2.2 Pie Chart with JPA 2.0 (John Yeary) • Typed Query RESTful Service Example (John Yeary) • How to set environment variables in GlassFish admin console (Jelastic) • Architect Enterprise Applications with Java EE (Oracle University) • Glassfish – Basic authentication (Marco Ghisellini) • Solving GlassFish 3.1/JSF PWC4011 warning (Rafael Nadal) • PrimeFaces AJAX Enabled (John Yeary)

    Read the article

  • How to extract a record in a text on string match in a file using bash

    - by private
    Hi I have a text file sample.txt as =====record1 title:javabook price:$120 author:john path:d: =====record2 title:.netbook author:paul path:f: =====record3 author:john title:phpbook subject:php path:f: price:$150 =====record4 title:phpbook subject:php path:f: price:$150 from this I want to split the data based on author, it should split into 2 files which contains test1.txt =====record1 title:javabook price:$120 author:john path:d: =====record3 author:john title:phpbook subject:php path:f: price:$150 and test2.txt =====record2 title:.netbook author:paul path:f: like above I want to classify the main sample.txt file into sub files based on author field dynamically. Please suggest me a way to do it.

    Read the article

  • Power Pivot - Average time per item

    - by Username
    I'm trying to calculate on average, how long it takes to make each item. Here is the data table: Date Item Quantity Operator 01/01/2014 Item1 3 John 01/01/2014 Item2 5 John 02/01/2014 Item1 7 Bob 02/01/2014 Item2 4 John 03/01/2014 Item1 2 Bob 07/01/2014 Item2 3 John On 01/01/2014 John made 3 of Item 1 and 5 of Item 2. If we only had the first 2 rows we can guess that it takes 0.375 days to make Item 1 and 0.625 days to make Item 2. I want to be able to calculate this on average using all the data and taking in to account the operators obviously working on different items. Thank you

    Read the article

  • Using Extended Events in SQL Server Denali CTP1 to Map out the TransactionLog SQL Trace Event EventSubClass Values

    - by Jonathan Kehayias
    John Samson ( Blog | Twitter ) asked on the MSDN Forums about the meaning/description for the numeric values returned by the EventSubClass column of the TransactionLog SQL Trace Event.  John pointed out that this information is not available for this Event like it is for the other events in the Books Online Topic ( TransactionLog Event Class ), or in the sys.trace_subclass_values DMV.  John wanted to know if there was a way to determine this information.  I did some looking and found...(read more)

    Read the article

  • Product Support Webcast for Existing Customers:Getting the Most from My Oracle Support, Tips and Tricks for WebCenter Content

    - by John Klinke
    My Oracle Support (MOS) is the one-stop support solution for WebCenter customers with Oracle Premier Support. Join us for this 1-hour Advisor Webcast "Getting the Most from My Oracle Support, Tips and Tricks for WebCenter Content" on July 11, 2013 at 11:00am Eastern (16:00 UK / 17:00 CET / 8:00am Pacific / 9:00am Mountain) Topics will include:- My Oracle Support Search, Advanced Search, and PowerViews- Information Centers- Latest Patches and Bundle Patches- My Oracle Support Community- Remote Diagnostic Administration (RDA) Make sure to register and mark this date on your calendar. Register here: https://oracleaw.webex.com/oracleaw/onstage/g.php?d=594341268&t=aOnce your registration request is approved, you will receive a confirmation email with instructions for joining the webcast on July 11. Past Advisor Webcasts have been recorded and can be viewed by going to the 'archived' tabs on this knowledge base announcement:https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=1456204.1 (active support contract required)

    Read the article

  • Recording Available: March 2012 Quarterly Customer Update Webcast

    - by John Klinke
    Missed the recent Quarterly Customer Update Webcast? We covered several topics including: * WebCenter 4 Pillars overview * Support Update * WebCenter Content 11gR1 Update * WebCenter Portal 11gR1 Update * Oracle Social Network Overview VIEW WEBCAST RECORDING: Access the March 2012 Webcast recording and presentation by going to: My Oracle Support Site Note: 568127.1 We'll announce the next Quarterly Customer Update Webcast here on the WebCenter Content Alerts blog.

    Read the article

  • Transmission-daemon not picking up on watch directory

    - by Mild Fuzz
    Trying to get my transmission-daemon to pick up files from a dropbox folder, to make remote starting easier (it's a headless system). As far as I can tell, the settings.json file is as expected, but none of the files I place in the folder get picked up. I have checked that dropbox is syncing correctly. Here is the whole settings.json file, but the relevant lines are included below: "watch-dir": "/home/john/Dropbox/torrents", "watch-dir-enabled": true Update It appears to be a permissions issue. From /var/log/syslog: Unable to watch "/home/john/Dropbox/torrents": Permission denied (watch.c:79) I have tried stopping the daemon - sudo service transmission-daemon stop - changing permissions of folder using chown - sudo chown -R john /home/john/Dropbox/torrents - restarting daemon - sudo service transmission-daemon start Same result, however Update 2 Permissions for the folder are: drwsrwsrwx 2 john debian-transmission 4096 2012-04-09 19:40

    Read the article

  • How to calculate running totals of subsets of data in a table

    - by John
    I have 4 columns: Name, Week, Batch and Units Produced (Cols, A,B,C,D). In column E, I need to keep running totals based on name and week. When the week changes for the same person, restart the total. Fred, 12, 4001, 129.0 Answer in e: 129.0 Fred, 12, 4012, 234.0 Answer in e: 363.0 Fred, 13, 4023, 12.0 Answer in e: 12.0 John, 12, 4003, 420.0 Answer in e: 420.0 John, 13, 4021, 1200.0 Answer in e: 1200.0 John, 13, 4029, 120.0 Answer in e: 1320.0 I need to be able to copy the formula to over 1000 rows.

    Read the article

  • Product Support Webcast for Existing Customers: Security Scenarios with Oracle WebCenter Content

    - by John Klinke
    Learn how user authentication and authorization is now implemented in Oracle WebCenter Content by attending this 1-hour Advisor Webcast "Security Scenarios with WebCenter Content" on September 27, 2012 at 11:00am Eastern (16:00 UK / 17:00 CET / 8:00am Pacific / 9:00am Mountain) This 1-hour session is recommended for technical and functional users of Oracle WebCenter Content. In this session, we will explain how user authentication and authorization is implemented in WebCenter Content 11g as well as ways that single sign-on (SSO) can be used. Topics will include: - How authentication and authorization was handled in previous WebCenter Content Server versions - The WebLogic Server mechanisms now used to provide user access and content security - Dealing with external and internal users - Overview of the WebLogic Server LDAP provider configuration - How to differentiate Roles and Accounts - WebCenter Content credential mapping - Single Sign-on (SSO) - SAML and Kerberos Register now at http://bit.ly/PH7zDj

    Read the article

  • Product Support Webcast for Existing Customers: WebCenter Content 11.1.1.8 Overview and Support Information

    - by John Klinke
    Register for our upcoming Advisor Webcast 'WebCenter Content 11.1.1.8 Overview and Support Information' scheduled for 11am Eastern, November 21, 2013 (10am Central, 9am Mountain, 8am Pacific, 17:00 Europe Time (Paris, GMT+01:00)).This 1-hour session is recommended for technical and functional users who have installed or plan to upgrade to WebCenter Content 11.1.1.8 or would just like more information on the latest release.Topics will include: Overview of new features and enhancements Installation of the new WebCenter Content web UI Upgrading from older WebCenter Content versions Support issues including latest patches Roadmap of proposed additional features Make sure you register and mark this date on your calendar. Register at: https://oracleaw.webex.com/oracleaw/onstage/g.php?d=590991341&t=aOnce the host approves your request, you will receive a confirmation email with instructions for joining the call on November 21st.

    Read the article

  • WebCenter Content Technical Resources

    - by John Klinke
    Some useful WebCenter Content technical resources that you might not be aware of: WebCenter Content Support's Twitter Account: Follow Oracle WebCenter Content Support on Twitter @OrcleWCCSupport to keep informed about webcasts, patches, new releases, tips and tricks, and more. Oracle WebCenter & ADF Architecture Team Blog: Frequent posts by the Oracle Fusion Middleware A-Team discussing WebCenter implementation and configuration topics.  

    Read the article

  • Product Support Webcast for Existing Customers: Oracle Webcenter Portal 11g User & Administration Tips

    - by John Klinke
    Register for our upcoming Advisor Webcast 'Oracle WebCenter Portal 11g: User & Administration Tips' scheduled for November 12, 2013 at 11:00 am, Eastern Standard Time (8:00 am Pacific Standard Time, 4:00 pm GMT Time, 5:00 pm Europe Time). This 1-hour session is recommended for technical and functional users who use Oracle WebCenter Portal to build company portals using run-time tools.Topics will include:• Whats new in 11.1.1.8 of WebCenter Portal• Terminology Changes• Using the Portal once its built• Setting up Self Registration (Admins)• End User Experience• Development Environment• Patching InformationFor more information and to register for this Advisor Webcast, please see Oracle WebCenter Portal 11g: User & Administration Tips (Doc ID 1585902.1).

    Read the article

  • Next Quarterly Customer Update Webcast is Nov 27th (Nov 28th in Asia Pacific)

    - by John Klinke
    Join the WebCenter team as we present the latest product direction that was recently shared at the Oracle OpenWorld conference in San Francisco last month.   This Oracle WebCenter Quarterly Customer Update Webcast is scheduled on Nov 27th (Nov 28th in Asia Pacific). We will also be sharing the latest product updates and key support announcements that all WebCenter professionals and solution owners need to know. Don’t miss out on getting the latest information.  There will be two live sessions with Q&A at the end of each session.   Register for Session 1 -  Nov 27th at 9am San Francisco, 12pm New York, and 5pm London Register for Session 2 – Nov 28th at 9am Singapore, 11am Sydney, and 6pm (Nov 27th) San Francisco

    Read the article

  • SQL Joining on a one-to-many relationship

    - by Harley
    Ok, here was my original question; Table one contains ID|Name 1 Mary 2 John Table two contains ID|Color 1 Red 1 Blue 2 Blue 2 Green 2 Black I want to end up with is ID|Name|Red|Blue|Green|Black 1 Mary Y Y 2 John Y Y Y It seems that because there are 11 unique values for color and 1000's upon 1000's of records in table one that there is no 'good' way to do this. So, two other questions. Is there an efficient way to query to get this result? I can then create a crosstab in my application to get the desired result. ID|Name|Color 1 Mary Red 1 Mary Blue 2 John Blue 2 John Green 2 John Black If I wanted to limit the number of records returned how could I do a query to do something like this? Where ((color='blue') AND (color<>'red' OR color<>'green')) So using the above example I would then get back ID|Name|Color 1 Mary Blue 2 John Blue 2 John Black I connect to Visual FoxPro tables via ADODB to use SQL. Thanks!

    Read the article

  • Simple Select Statement on MySQL Database Hanging

    - by AlishahNovin
    I have a very simple sql select statement on a very large table, that is non-normalized. (Not my design at all, I'm just trying to optimize while simultaneously trying to convince the owners of a redesign) Basically, the statement is like this: SELECT FirstName, LastName, FullName, State FROM Activity Where (FirstName=@name OR LastName=@name OR FullName=@name) AND State=@state; Now, FirstName, LastName, FullName and State are all indexed as BTrees, but without prefix - the whole column is indexed. State column is a 2 letter state code. What I'm finding is this: When @name = 'John Smith', and @state = '%' the search is really fast and yields results immediately. When @name = 'John Smith', and @state = 'FL' the search takes 5 minutes (and usually this means the web service times out...) When I remove the FirstName and LastName comparisons, and only use the FullName and State, both cases above work very quickly. When I replace FirstName, LastName, FullName, and State searches, but use LIKE for each search, it works fast for @name='John Smith%' and @state='%', but slow for @name='John Smith%' and @state='FL' When I search against 'John Sm%' and @state='FL' the search finds results immediately When I search against 'John Smi%' and @state='FL' the search takes 5 minutes. Now, just to reiterate - the table is not normalized. The John Smith appears many many times, as do many other users, because there is no reference to some form of users/people table. I'm not sure how many times a single user may appear, but the table itself has 90 Million records. Again, not my design... What I'm wondering is - though there are many many problems with this design, what is causing this specific problem. My guess is that the index trees are just too large that it just takes a very long time traversing the them. (FirstName, LastName, FullName) Anyway, I appreciate anyone's help with this. Like I said, I'm working on convincing them of a redesign, but in the meantime, if I someone could help me figure out what the exact problem is, that'd be fantastic.

    Read the article

  • Is adding users to the group www-data safe on Debian?

    - by John
    Many PHP applications do self-configuration and self-updating. This requires apache to have write access to the PHP files. While chgrp'ing them all to www-data appears like a good practice to avoid making them world writable, I also wish to allow users to create new files and edit existing one. Is adding users to the group www-data safe on Debian? For example: 775 root www-data /var/www 644 john www-data /var/www/johns_php_application.php 660 john www-data /var/www/johns_php_applications_configuration_file

    Read the article

  • Handwritten linked list is segfaulting and I don't understand why

    - by Born2Smile
    Hi I was working on a bit of fun, making an interface to run gnuplot from within c++, and for some reason the my linked list implementation fails. The code below fails on the line plots-append(&plot). Stepping through the code I discovered that for some reason the destructor ~John() is called immediately after the constructor John(), and I cannot seem to figure out why. The code included below is a stripped down version operating only on Plot*. Originally I made the linked list as a template class. And it worked fine as ll<int and ll<char* but for some reason it fails as ll<Plot*. Could youp please help me figure out why it fails? and perhaps help me understand how to make it work? In advance: Thanks a heap! //B2S #include <string.h class Plot{ char title[80]; public: Plot(){ } }; class Link{ Plot* element; Link* next; Link* prev; friend class ll; }; class ll{ Link* head; Link* tail; public: ll(){ head = tail = new Link(); head-prev = tail-prev = head-next = tail-next = head; } ~ll(){ while (head!=tail){ tail = tail-prev; delete tail-next; } delete head; } void append(Plot* element){ tail-element = element; tail-next = new Link(); tail-next-prev = tail; tail-next = tail; } }; class John{ ll* plots; public: John(){ plots= new ll(); } ~John(){ delete plots; } John(Plot* plot){ John(); plots-append(plot); } }; int main(){ Plot p; John k(&p); }

    Read the article

  • SQL Server Distinct Question

    - by RPS
    I need to be able to select only the first row for each name that has the greatest value. I have a table with the following: id name value 0 JOHN 123 1 STEVE 125 2 JOHN 127 3 JOHN 126 So I am looking to return: id name value 1 STEVE 125 2 JOHN 127 Any idea on the MSSQL Syntax on how to perform this operation?

    Read the article

  • string.Replace does not work for quote

    - by Azhar
    ((string)dt.Rows[i][1]).Replace("'", "\'") I want the result that if any string have quote it change it into slash quote e.g John's - John\'s but the above replace function is not working fine. it results like John\'s but if we change the code to ((string)dt.Rows[i][1]).Replace("'", "\'") it gives the Result like John's does change it anyway.

    Read the article

  • PHP Find and replace after in a string?

    - by TheBlackBenzKid
    I have some strings which contain the words LIMIT 3, 199 or LIMIT 0, 100. Basically I want to replace the word LIMIT and everything after it in my string. How do I do this in PHP? str_replace only replaces an item and the LIMIT text after is dynamic/ So it could be WHEN JOHN WAS TRYING HIS SQL QUERY, HE FOUND THAT LIMIT, 121 // RETURN WOULD BE WHEN JOHN WAS TRYING HIS SQL QUERY, HE FOUND THAT WHEN JOHN TRIED LIMIT 343, 333 HE FOUND // RETURN WOULD BE WHEN JOHN TRIED

    Read the article

  • Exchange 2010 OWA - a few questions about using multiple mailboxes

    - by Alexey Smolik
    We have an Exchange 2010 SP2 deployment and we need that our users could access multiple mailboxes in OWA. The problem is that a user (eg John Smith) needs to access not just somebody else's (eg Tom Anderson) mailboxes, but his OWN mailboxes, e.g. in different domains: john[email protected], john[email protected], john[email protected], etc. Of course it is preferable for the user to work with all of his mailboxes from a single window. Such mailboxes can be added as multiple Exchange accounts in Outlook, that works almost fine. But in OWA, there are problems: 1) In the left pane - as I've learned - we can open only Inbox folders from other mailboxes. No way to view all folders like in Outlook? 2) With Send-As permissions set, when trying to send a message from another address, that message is saved in the Sent Items folder of the mailbox that is opened in OWA, and not in the mailbox the message is sent from. The same thing with the trash can. Is there a way to fix that? Also, this problem exists in desktop Outlook when mailboxes are added automatically via the Auto Mapping feature, so that we need to turn it off and add the accounts manually. Is there a simpler workaround? 3) Okay, suppose we only open Inbox folders in the left pane. The problem is that the mailbox names shown there are formed from Display Name attributes. But those names are all identical! All the mailboxes are owned by John Smith, so they should be all named John Smith - so that letter recepient sees "John Smith" in the "from" field, no matter what mailbox it is sent from. Also, the user knows what's his name - no need to tell him. He wants to know what mailbox he works with. So we need a way to either: a) customize OWA to show mailbox email address instead of user Display Name, or b) make Exchange use another attribute to put in the "from" field when sending letters 4) Okay, we can switch between mailboxes using "Open Other Mailbox" in the upper-right corner menu. But: a) To select a mailbox we need to enter its name (or first letters). It there a way to show a list of links to mailboxes the user has full access to? Eg in the page header... b) If we start entering the first letters, we see a popup list with possible mailboxes to be opened. But there are all mailboxes (apparently from GAL), not only mailboxes the user has permission to open! How to filter that popup list? c) The same problem as in (3) with mailbox naming. We can see the opened mailbox email address ONLY in the page URL, which is insufficient for many users. In the left pane we see "John Smith" which is useless. 5) Each mailbox is tied with a separate user in AD. If one has several mailboxes, we need to have additional dummy AD accounts, create additional OUs to store them, etc. That's not very nice, is there any standartized, optimal way to build such a structure? We would really appreciate any answers or additional info for any of these questions. Thank you in advance.

    Read the article

  • Rhythmbox 2.99.1 crashes when playing any song on Ubuntu 13.10

    - by John H
    Yesterday rhythmbox was running smoothly but today it crashes only a few seconds after I hit the play button, regardless of track. I've tried disabling plugins, re-installing rhythmbox via synaptics, clearing the library and the rhythmdb.xml-file and just adding one album. Still, it crashes. If I run the rhythmbox from the command line i get the following before I have to force quit: :~$ rhythmbox Failed to create secure directory (/run/user/1000/pulse): Permission denied Killed :~$ However, if i run rhythmbox via the command line as superuser it does work. But i get the following errors: sudo rhythmbox (rhythmbox:8335): Gtk-WARNING **: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files (rhythmbox:8335): IBUS-WARNING **: The owner of /home/john/.config/ibus/bus is not root! (rhythmbox:8335): Rhythmbox-WARNING **: Unable to grab media player keys: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SettingsDaemon was not provided by any .service files Traceback (most recent call last): File "/usr/lib/rhythmbox/plugins/rb/Loader.py", line 47, in _contents_cb (ok, contents, etag) = file.load_contents_finish(result) gi._glib.GError: Operation not supported Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/gi/overrides/GLib.py", line 634, in return (lambda data: callback(*data), user_data) […] I'm running rhythmbox on a Lenovo e335 thikpad edge. I hope I've supplied enough information. Cheers -John

    Read the article

  • Mexico leading in Business Transformation Strategies:

    - by [email protected]
    By john[email protected] on April 15, 2010 8:31 AM By John Burke Group Vice President Oracle Applications Business Unit I recently completed a business tour in Mexico, and was surprised by both the economic vibrancy of the country and the thought leadership expressed by many of the customers I met. An example of the economic vibrancy of the country: across the street from my hotel was the local Bentley dealership, Coach Store, Yves Saint Laurent and of course a Starbucks. I only made it to Starbucks. Both the Coach Store and YSL had a line of folks waiting to get in... As for thought leadership, there were several illustrations only on the first day. I had the opportunity to meet with a branch of the Mexican Federal Government. Their questions were not about clerical task automation, far from it! We discussed citizen on-line access to fees and services - for example looking up the duty on an international goods shipment, or tracking that my taxes have been received, or the status of my request for a certain service. Eligibility, policies and status. Having an integrated rules or policy automation system that would allow businesses and citizens to access accurate information and ensure the proper collection of fees and payment for 3rd party provided services. Then in the afternoon, I met with the owner of a roofing company (note: most roofs in Mexico are flat and made of cement). This CEO started discussing how he wanted to transform his business from a cement products company to a service company and market 5-10-15 year service contracts which would guarantee the structural integrity of the roof and of course that the roof would remain waterproof. Although his products were guaranteed, they required an annual inspection and most home owners never schedule that inspection until it is too late and water damage has occurred. These emergency calls reduce his margin and reduce customer satisfaction. This lead to a discussion of business models in general and why long term differentiation can only come from service, not just for the music or news industries, but also for roofing companies! I completely agreed with the transformational concepts described in both meetings and quickly understood why there is a Bentley dealership near my hotel.

    Read the article

  • Ubuntu 12.10 unmet dependencies

    - by John
    I have Ubuntu 12.10 with 3.2.0.24-generic #39-Ubuntu running on a Dell Inspiron 700m laptop. I have unmet dependencies as follows: root@John-700m:/home/John# sudo apt-get remove --purge linux-image-3.5.0-{18,27,31,34}-generic Reading package lists... Done Building dependency tree Reading state information... Done Package 'linux-image-3.5.0-18-generic' is not installed, so not removed Package 'linux-image-3.5.0-27-generic' is not installed, so not removed Package 'linux-image-3.5.0-31-generic' is not installed, so not removed Package 'linux-image-3.5.0-34-generic' is not installed, so not removed You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: linux-generic : Depends: linux-image-generic but it is not going to be installed linux-image-extra-3.5.0-18-generic : Depends: linux-image-3.5.0-18-generic but it is not going to be installed linux-image-extra-3.5.0-27-generic : Depends: linux-image-3.5.0-27-generic but it is not going to be installed linux-image-extra-3.5.0-31-generic : Depends: linux-image-3.5.0-31-generic but it is not going to be installed linux-image-extra-3.5.0-34-generic : Depends: linux-image-3.5.0-34-generic but it is not going to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). I tried to remove the packages, but I still get the same error message. Any help would certainly be appreciated. @Eric, well noted. Here is the reults: model name : Intel(R) Pentium(R) M processor 1.60GHz flags : fpu vme de pse tsc msr mce cx8 mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe up bts est tm2 Thanks again. @Eric, If I need to downgrade to Ubuntu 12.04 from 12.10, can I do it without having to mess my current partition or files? I also have Windows XP running on the machine. Best. @Eric, if you are online, I could use your help (or anybody's else). I installed the package for non-pae unit and I still get the same error. Any suggestions? Thanks

    Read the article

  • To ref or not to ref

    - by nmarun
    So the question is what is the point of passing a reference type along with the ref keyword? I have an Employee class as below: 1: public class Employee 2: { 3: public string FirstName { get; set; } 4: public string LastName { get; set; } 5:  6: public override string ToString() 7: { 8: return string.Format("{0}-{1}", FirstName, LastName); 9: } 10: } In my calling class, I say: 1: class Program 2: { 3: static void Main() 4: { 5: Employee employee = new Employee 6: { 7: FirstName = "John", 8: LastName = "Doe" 9: }; 10: Console.WriteLine(employee); 11: CallSomeMethod(employee); 12: Console.WriteLine(employee); 13: } 14:  15: private static void CallSomeMethod(Employee employee) 16: { 17: employee.FirstName = "Smith"; 18: employee.LastName = "Doe"; 19: } 20: }   After having a look at the code, you’ll probably say, Well, an instance of a class gets passed as a reference, so any changes to the instance inside the CallSomeMethod, actually modifies the original object. Hence the output will be ‘John-Doe’ on the first call and ‘Smith-Doe’ on the second. And you’re right: So the question is what’s the use of passing this Employee parameter as a ref? 1: class Program 2: { 3: static void Main() 4: { 5: Employee employee = new Employee 6: { 7: FirstName = "John", 8: LastName = "Doe" 9: }; 10: Console.WriteLine(employee); 11: CallSomeMethod(ref employee); 12: Console.WriteLine(employee); 13: } 14:  15: private static void CallSomeMethod(ref Employee employee) 16: { 17: employee.FirstName = "Smith"; 18: employee.LastName = "Doe"; 19: } 20: } The output is still the same: Ok, so is there really a need to pass a reference type using the ref keyword? I’ll remove the ‘ref’ keyword and make one more change to the CallSomeMethod method. 1: class Program 2: { 3: static void Main() 4: { 5: Employee employee = new Employee 6: { 7: FirstName = "John", 8: LastName = "Doe" 9: }; 10: Console.WriteLine(employee); 11: CallSomeMethod(employee); 12: Console.WriteLine(employee); 13: } 14:  15: private static void CallSomeMethod(Employee employee) 16: { 17: employee = new Employee 18: { 19: FirstName = "Smith", 20: LastName = "John" 21: }; 22: } 23: } In line 17 you’ll see I’ve ‘new’d up the incoming Employee parameter and then set its properties to new values. The output tells me that the original instance of the Employee class does not change. Huh? But an instance of a class gets passed by reference, so why did the values not change on the original instance or how do I keep the two instances in-sync all the times? Aah, now here’s the answer. In order to keep the objects in sync, you pass them using the ‘ref’ keyword. 1: class Program 2: { 3: static void Main() 4: { 5: Employee employee = new Employee 6: { 7: FirstName = "John", 8: LastName = "Doe" 9: }; 10: Console.WriteLine(employee); 11: CallSomeMethod(ref employee); 12: Console.WriteLine(employee); 13: } 14:  15: private static void CallSomeMethod(ref Employee employee) 16: { 17: employee = new Employee 18: { 19: FirstName = "Smith", 20: LastName = "John" 21: }; 22: } 23: } Viola! Now, to prove it beyond doubt, I said, let me try with another reference type: string. 1: class Program 2: { 3: static void Main() 4: { 5: string name = "abc"; 6: Console.WriteLine(name); 7: CallSomeMethod(ref name); 8: Console.WriteLine(name); 9: } 10:  11: private static void CallSomeMethod(ref string name) 12: { 13: name = "def"; 14: } 15: } The output was as expected, first ‘abc’ and then ‘def’ - proves the 'ref' keyword works here as well. Now, what if I remove the ‘ref’ keyword? The output should still be the same as the above right, since string is a reference type? 1: class Program 2: { 3: static void Main() 4: { 5: string name = "abc"; 6: Console.WriteLine(name); 7: CallSomeMethod(name); 8: Console.WriteLine(name); 9: } 10:  11: private static void CallSomeMethod(string name) 12: { 13: name = "def"; 14: } 15: } Wrong, the output shows ‘abc’ printed twice. Wait a minute… now how could this be? This is because string is an immutable type. This means that any time you modify an instance of string, new memory address is allocated to the instance. The effect is similar to ‘new’ing up the Employee instance inside the CallSomeMethod in the absence of the ‘ref’ keyword. Verdict: ref key came to the rescue and saved the planet… again!

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >