Appellant, who- was plaintiff below, is a railway corporation organized und’er the laws of this state. There are two alleged causes of action set out in the complaint, to each of which demurrer was interposed on the ground that the facts stated were not sufficient to constitute a cause of action. The demurrers were sustained, and plaintiff appeals.
By the first alleged cause of action it appears, in substance, that in January, 1906, plaintiff was about to construct a certain line of railway in a westerly direction from- the city of Watertown across this state, and that it entered into a contract with defendant Thomas A. Way, whérein and whereby he promised and agreed, at his own expense, to secure and convey and transfer, free of in-cumbrance, iby good title, to' plaintiff, between certain designated points, all the necessary right of way and depot grounds sufficient for the construction and operation of said contemplated railway, in consideration of the agreement that plaintiff would permit said Way to purchase and lay out town sites upon and along said contemplated line of railway, between said designated points, at such ■points as the chief engineer of said railway company should designate ; that plaintiff performed said contract on its part, but that said Way has failed to purchase and convey to plaintiff a large part of said right of way and depot grounds, and by reason thereof plaintiff was compelled to, and did, expend large stated sums of money in itself securing such right of way contracted to' be secured by said Way; that said Thomas A. Way„ to secure the *438faithful performance of said contract, entered into a bond, with others of the respondents as sureties; and that there has been a breach in the conditions of said bond to plaintiff’s injury.
By the second alleged cause of action it, in substance, appears that under said contract alleged in 'the first cause of action, and upon the same consideration, said Thomas A. Way, along portions of said contemplated line of railway, agreed to purchase at his own expense lands for town sites, to lay out and to plat into lots and blocks such towns at such points as the chief engineer of plaintiff should designate; that said Way should sell and dispose of said lots and blocks, and that when so sold the entire proceeds arising from such sales, after deducting the actual cost of the land and platting and 5 per cent, commission for sales, should be divided between plaintiff and said Way; that for the purpose of facilitating the purposes of said contract the said Way caused to be organized the defendant Dakota Town Lot Company; that said Way and said town lot company secured real estate at certain designated stations along said line of railway in' the counties of Codington, Clark, and Day, and platted the same into lots and blocks, and made many sales of such lots and blocks, and has accounted to plaintiff for only a portion of its share of the proceeds of such sales, and that there is still due and unpaid to plaintiff large sums of money by reason thereof, and demand has been made upon defendants for payment which has been refused, and that by reason thereof another breach of the conditions of said bond exists to plaintiff’s injury.
[1] It is contended by respondents that the said contract, which constituted the basis of said alleged causes of action on the part of plaintiff, is wholly without consideration and nudum 'pactum, on the ground that said contract is illegal and void as-being against public policy. We are constrained to the view that respondents are right in this contention. The statute of this state (section 1271, Civ. Code) provides:
“That is not lawful which is (1) Contrary to an express provision of law; (2) contrary to the policy of express law, though not expressly prohibited; or (3) otherwise contrary to good" morals.”
It is not always easy to' define just what facts will constitute “contrary to good morals” within the meaning of this statute; but *439every case must stand generally upon its own peculiar facts and circumstances.
Public Service corporations, such as railway companies, are charged with a trust, and owe a duty to the general public in the' matter of the location of stations and depots, which duty is to so locate such stations and depots as will best serve the public interests ; and any contract entered into by such corporations- which has a tendency to interfere or come in conflict with the full and proper exercise of such trust duty will be an illegal contract and against good morals, within the meaning of the statute. In Halladay v. Patterson, 5 Or. 177, it was held that a railway company is a quasi public corporation, and that the public has an interest in the location of their lines of road and depots, and that an agreement which tends to lead persons charged with the performance of trusts or duties for the benefit of others, to violate or betray them, will not be enforced. This decision is recognized as one of the leading authorities upon this proposition. Elliott, Contracts, §§ 750, 751. The following from Cyc. -is a good exposition of the rule:
“If an agreement binds the parties or either of them, or if the consideration is to do something opposed to public policy, it is illegal and absolutely void, however solemnly made. If a court should enfoixe such an agreement it would employ its functions in undoing what it was created' to do. It is not easy to give a precise definition of public policy. It -is perhaps correct to say that public policy is that principle of .law which holds that no person can lawfully do that which has a tendency to be injurious to- the public, or against the public good, which may be designated, as it sometimes has been, the policy of the law or public policy in relation to the administration of the law. Where a contract belongs to this class, it will be declared void, although in the particular instance no injury to the public may have resulted. In other words, its validity is determined by its general tendency at the time it is made, and if this is opposed to the interests of the public it will be invalid, even if the intent of all the parties was good, and no -injury to the public would result in the particular case. The test is the evil tendency of the contract, and not its actual injury to the public in a particular instance. Thus an agreement for a pecuniary consideration made by a railroad company for the location of a station or depot at some particular place is void, although the *440location in the particular case may be advantageous to the public. An agreement to influence legislation is void, although the legislation sought may be clearly beneficial. An agreement to influence appointment to office is void, although the intent may 'be to secure the best qualified person. The law looks to the general tendency of such agreements, and it closes the doors to temptations by refusing them recognition in any of its courts.” 9 Cyc. 481-498.
[2] The fair and reasonable inference to' -be drawn from the spirit and intent of the contract set out in the complaint was that, as consideration for the said Way securing and conveying to appellant free of cost a right of way on .which to' construct its line of road, it would secretly impart to him inside advance information as to the points where stations and depots were to- be located on said contemplated line of railway, to the end tiiat said Way might, in advance of all other persons, purchase the lands for town sites at such points as the chief engineer of the road should designate, and that appellant would protect him. by erecting depots and establishing stations at such points as he might purchase such lands for town-site purposes. The direct tendency of this contract was to cause the location of stations and depots at such points as best conserved the pecuniary interests of said parties thereto. Thereby the appellant secured its right of way and an interest in the proceeds of the sales of certain town lots. Thereby all other persons who might have desired to locate town sites along said line were indirectly deterred from so doing. The dickering and speculating in town-site properties is not within the scope of the authority of railway corfipanies organized under the laws of this state. The securing by appellant of its right of way and an interest in the proceeds of said town-site sales by this method was in direct conflict with the-trust duties the appellant owed to the general public. It seems to be a settled policy of the law to remove such opportunities and temptations by refusing to take cognizance of or enforce such contracts. Therefore, we are of the view that the contract which forms the basis of this action was without consideration, ultra vires, and illegal and void. The appellant had no legal authority to “permit” that which constituted the consideration for this contract. It was an illegal consideration, which, in effect, was no consideration. Many authorities sustain this view, among which are the following: Williamson v. C., R. I. & P. Ry., *44153 Iowa, 126, 4 N. W. 870, 36 Am. Rep. 206; Reed v. Johnson, 27 Wash. 42, 67 Pac. 381, 57 L. R. A. 404; Western U. Telegraph Co. y. U. P. Ry. (C. C.) 3 Fed. 1; Woodstock v. Richmond Co., 129 U. S. 643, 9 Sup. Ct. 402, 32 L. Ed. 819; Bestor v. Wathen, 60 Ill. 138; St. Louis Ry. v. Mathers, 71 Ill. 592, 22 Am. Rep. 112 ; Pac. Ry. v. Seely, 45 Mo. 212, 100 Am. Dec. 369; Central Trans. Co. v. Pullman Car Co., 139 U. S. 24, 11 Sup. Ct. 478, 35 L. Ed. 55; Page on Contracts, § 416; Elliott on Contracts, §§ 75°. 751•
[3] Appellant contends that” notwithstanding the contract might have been ultra vires and void, respondent, having received the full benefits thereunder, is now estopped to assert the invalidity thereof. The contract here involved was not only void by reason of its being ultra vires, but it was also void on the ground of illegality. There is a marked distinction between contracts which are void merely by reason of being ultra vires and contracts which-are void by reason of being both ultra vires and illegal. Page-on Contracts, § 506; Elliott on Contracts, § 645. Validity cannot be given to an illegal' contract through any principle of estoppel. As between parties in pari delicto, the courts will leave them where it has found them. Courts will not adjudicate rights under illegal contracts. Reed v. Johnson, supra; Williamson v. Ry. Co., supra; Page on Contracts, § 507.
The judgment and order appealed from are affirmed.